Pagini recente » Cod sursa (job #2216438) | Cod sursa (job #1632731) | Cod sursa (job #932337) | Cod sursa (job #1893302) | Cod sursa (job #1497949)
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.util.Scanner;
public class Main {
public static int cmmdc(int x, int y){
int cmmdc = 0;
while(x!=y){
if(x >= y)
x -= y;
else y -= x;
}
cmmdc = x;
return cmmdc;
}
public static boolean isIreductible(int x, int y){
boolean toReturn = false;
if(cmmdc(x,y) == 1)
toReturn = true;
else toReturn = false;
return toReturn;
}
public static int solution(int n){
int nr = 0;
for(int i=1; i<=n; ++i)
for(int j=1; j<=n; ++j)
if(isIreductible(i,j))
++nr;
return nr;
}
public static void main(String args[]) throws FileNotFoundException{
Scanner sc = new Scanner(new FileInputStream("fractii.in"));
int n = sc.nextInt();
PrintWriter writer = new PrintWriter("fractii.out");
writer.write(""+solution(n));
writer.close();
sc.close();
}
}