Chowla numbers: Difference between revisions
Added Arturo implementation
Not a robot (talk | contribs) (Add MAD) |
Drkameleon (talk | contribs) (Added Arturo implementation) |
||
Line 198:
33550336 is a perfect number
There are 5 perfect numbers < 350000000</pre>
=={{header|Arturo}}==
<lang rebol>chowla: function [n]-> sum remove remove factors n 1 n
countPrimesUpTo: function [limit][
count: 1
loop 3.. .step: 2 limit 'x [
if zero? chowla x -> count: count + 1
]
return count
]
loop 1..37 'i -> print [i "=>" chowla i]
print ""
loop [100 1000 10000 100000 1000000 10000000] 'lim [
print ["primes up to" lim "=>" countPrimesUpTo lim]
]
print ""
print "perfect numbers up to 35000000:"
i: 2
while [i < 35000000][
if (chowla i) = i - 1 -> print i
i: i + 2
]</lang>
{{out}}
<pre>1 => 0
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
primes up to 100 => 25
primes up to 1000 => 168
primes up to 10000 => 1229
primes up to 100000 => 9592
primes up to 1000000 => 78498
primes up to 10000000 => 664579
perfect numbers up to 35000000:
6
28
496
8128
33550336</pre>
=={{header|AWK}}==
|