-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEuler_phi.java
More file actions
38 lines (36 loc) · 826 Bytes
/
Euler_phi.java
File metadata and controls
38 lines (36 loc) · 826 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import java.util.*;
class Euler_phi{
/*static intgcd(a,b){
if(a==0){
return b;
}
return gcd(b%a,a);
} */
static int Gcd (int a,int b){
int c=1;
if(a<b){
for(int i=1;i<=a;i++){
if(a%i==0){
if(b%i==0){
if(c<=i){
c=i;
}
}
}
}
}
return c;
}
public static void main(String args[]){
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int count=0;
for(int i=1;i<n;i++){
if(Gcd(i,n)==1){
System.out.println(i);
count++;
}
}
System.out.println("Total number of coprimes possible in pair(i,"+n+") is:"+count);
}
}