Chowla numbers: Difference between revisions

Content added Content deleted
(Added C code)
No edit summary
Line 1,608: Line 1,608:
Same as Go example.
Same as Go example.
</pre>
</pre>

=={{header|Maple}}==
<lang Maple>ChowlaFunction := n -> NumberTheory:-SumOfDivisors(n) - n - 1;
PrintChowla := proc(n::posint) local i;
printf("Integer : Chowla Number\n");
for i to n do
printf("%d : %d\n", i, ChowlaFunction(i));
end do;
end proc:
countPrimes := n -> nops([ListTools[SearchAll](0, map(ChowlaFunction, [seq(1 .. n)]))]);
findPerfect := proc(n::posint) local to_check, found, k;
to_check := map(ChowlaFunction, [seq(1 .. n)]);
found := [];
for k to n do
if to_check(k) = k - 1 then
found := [found, k];
end if;
end do;
end proc:
PrintChowla(37);
countPrimes(100);
countPrimes(1000);
countPrimes(10000);
countPrimes(100000);
countPrimes(1000000);
countPrimes(10000000);
findPerfect(35000000)</lang>
{{Out}}
<pre>
Integer : Chowla Number
1 : -1
2 : 0
3 : 0
4 : 2
5 : 0
6 : 5
7 : 0
8 : 6
9 : 3
10 : 7
11 : 0
12 : 15
13 : 0
14 : 9
15 : 8
16 : 14
17 : 0
18 : 20
19 : 0
20 : 21
21 : 10
22 : 13
23 : 0
24 : 35
25 : 5
26 : 15
27 : 12
28 : 27
29 : 0
30 : 41
31 : 0
32 : 30
33 : 14
34 : 19
35 : 12
36 : 54
37 : 0
25
168
1229
9592
78498
664579
[6, 28, 496, 8128, 33550336]</pre>

=={{header|Pascal}}==
=={{header|Pascal}}==
{{works with|Free Pascal}}
{{works with|Free Pascal}}