fork(1) download
  1. 1.upto(100){|i|
  2. c1=0
  3. 1.upto(i){|j|
  4. c1+=1 if i.gcd(j)==1
  5. }
  6. #puts i.to_s+","+c1.to_s+","+(i-c1).to_s
  7. }
  8. cs=[0]*200
  9.  
  10. 100.downto(2){|i|
  11. if cs[i]==0 then
  12. c1=0
  13. n1=i
  14. while n1<=100
  15. c1+=1 if 0==cs[n1]
  16. cs[n1]+=c1
  17. n1+=i
  18. end
  19. end
  20. }
  21. 1.upto(100){|i|
  22. puts [i,i-cs[i],cs[i]].join(",")
  23. }
Success #stdin #stdout 0.01s 8088KB
stdin
Standard input is empty
stdout
1,1,0
2,1,1
3,2,1
4,2,2
5,4,1
6,3,3
7,6,1
8,5,3
9,7,2
10,7,3
11,10,1
12,7,5
13,12,1
14,11,3
15,12,3
16,12,4
17,16,1
18,13,5
19,18,1
20,15,5
21,18,3
22,19,3
23,22,1
24,17,7
25,23,2
26,23,3
27,24,3
28,23,5
29,28,1
30,23,7
31,30,1
32,27,5
33,30,3
34,31,3
35,32,3
36,28,8
37,36,1
38,35,3
39,36,3
40,33,7
41,40,1
42,35,7
43,42,1
44,39,5
45,40,5
46,43,3
47,46,1
48,39,9
49,47,2
50,45,5
51,48,3
52,47,5
53,52,1
54,47,7
55,52,3
56,49,7
57,54,3
58,55,3
59,58,1
60,49,11
61,60,1
62,59,3
63,58,5
64,58,6
65,62,3
66,59,7
67,66,1
68,63,5
69,66,3
70,63,7
71,70,1
72,61,11
73,72,1
74,71,3
75,70,5
76,71,5
77,74,3
78,71,7
79,78,1
80,71,9
81,77,4
82,79,3
83,82,1
84,73,11
85,82,3
86,83,3
87,84,3
88,81,7
89,88,1
90,79,11
91,88,3
92,87,5
93,90,3
94,91,3
95,92,3
96,85,11
97,96,1
98,93,5
99,94,5
100,92,8