import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringBuffer sb = new StringBuffer("");
String m="";
while((m=br.readLine())!=null) {
sb.append(compStars(Integer.parseInt(m))).append("\n");
}
System.out.print(sb);
}
static int compStars(int in){
int ans=1;
int x=in;
for(int i=2;i<=Math.sqrt(x)+1;i++){
if(x%i==0){
x/=i;
ans*=(i-1);
while(x%i==0){
x/=i;
ans*=i;
}
}
}
if(x>1){
ans*=(x-1);
}
return ans/2;
}
}
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringBuffer sb = new StringBuffer("");
String m="";
while((m=br.readLine())!=null) {
sb.append(compStars(Integer.parseInt(m))).append("\n");
}
System.out.print(sb);
}
static int compStars(int in){
int ans=1;
int x=in;
for(int i=2;i<=Math.sqrt(x)+1;i++){
if(x%i==0){
x/=i;
ans*=(i-1);
while(x%i==0){
x/=i;
ans*=i;
}
}
}
if(x>1){
ans*=(x-1);
}
return ans/2;
}
}
No comments:
Post a Comment