Cod sursa(job #2046387)

Utilizator alexc11Alex C alexc11 Data 23 octombrie 2017 19:18:15
Problema Fractii Scor 10
Compilator c Status done
Runda Arhiva de probleme Marime 0.75 kb
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/* 
 * File:   main.c
 * Author: alexc
 *
 * Created on 23 octombrie 2017, 18:53
 */

#include <stdio.h>
#include <stdlib.h>

/*
 * 
 */
int n, i, j, k;
int unu(int a, int b) {
    while (a!=b) {
        if (a>b) a-=b;
        else b-=a;
    }
    return a;
}
int main() {
    FILE *f = fopen("fractii.in","r");
    FILE *g = fopen("fractii.out","w");
    fscanf(f, "%d", &n);
    for (i=2; i<=n; i++) {
        for (j=1; j<=n; j++)
            if (unu(i,j)==1) {
                k++;
                //printf("%d %d \n",i,j);
            }
    }
    fprintf(g, "%d", k+n);
}