-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSquareFree.java
More file actions
56 lines (51 loc) · 1.2 KB
/
SquareFree.java
File metadata and controls
56 lines (51 loc) · 1.2 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import java.util.*;
import java.io.*;
import java.util.ArrayList;
import java.util.List;
import java.util.SortedSet;
import java.util.TreeSet;
public class SquareFree {
public static double calculate(double b) {
double c = b;
SortedSet <Double> factors = new TreeSet<Double>();
for (double i = 2; i <= c; i++) {
while (c % i == 0) {
factors.add(i);
c = c/i;
}
}
double d = check(factors.size());
return d;
}
public static double check(int e){
double f=e;
List <Double> cdd = new ArrayList<Double>();
for(int r = 0; r<=f;r++){
double ncr = fact(f) / (fact(r) * fact(f - r));
cdd.add(ncr);
}
return cdd.size();
}
public static double fact(double z)
{
double k = 1, s;
if (z == 0)
{
return(k);
}
else
{
for ( s = 1; s <= z; s++)
{
k = k * s;
}
}
return(k);
}
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new
InputStreamReader(System.in));
long a = Integer.parseInt(br.readLine());
System.out.println((int)calculate(a));
}
}