Anti-primes: Difference between revisions
Content deleted Content added
→{{header|Haskell}}: hlint, hindent. Specified imports, added type signatures. |
No edit summary |
||
Line 1: | Line 1: | ||
{{task}} |
{r{task}} |
||
[[Category:Prime numbers]] |
[[Category:Prime numbers]] |
||
Line 1,146: | Line 1,146: | ||
return $+1 /*bump "proper divisors" to "divisors".*/</lang> |
return $+1 /*bump "proper divisors" to "divisors".*/</lang> |
||
{{out|output|text= is identical to the 1<sup>st</sup> REXX version.}} <br><br> |
{{out|output|text= is identical to the 1<sup>st</sup> REXX version.}} <br><br> |
||
=={{header|Ring}}== |
|||
<lang ring> |
|||
# Project : ANti-primes |
|||
see "working..." + nl |
|||
see "wait for done..." + nl + nl |
|||
see "the first 20 anti-primes are:" + nl + nl |
|||
maxDivisor = 0 |
|||
num = 0 |
|||
n = 0 |
|||
result = list(20) |
|||
while num < 20 |
|||
n = n + 1 |
|||
div = factors(n) |
|||
if (div > maxDivisor) |
|||
maxDivisor = div |
|||
num = num + 1 |
|||
result[num] = n |
|||
ok |
|||
end |
|||
see "[" |
|||
for n = 1 to len(result) |
|||
if n < len(result) |
|||
see string(result[n]) + "," |
|||
else |
|||
see string(result[n]) + "]" + nl + nl |
|||
ok |
|||
next |
|||
see "done..." + nl |
|||
func factors(an) |
|||
ansum = 2 |
|||
if an < 2 |
|||
return(1) |
|||
ok |
|||
for nr = 2 to an/2 |
|||
if an%nr = 0 |
|||
ansum = ansum+1 |
|||
ok |
|||
next |
|||
return ansum |
|||
</lang ring> |
|||
{{out}} |
|||
<pre> |
|||
working... |
|||
wait for done... |
|||
the first 20 anti-primes are: |
|||
[1,2,4,6,12,24,36,48,60,120,180,240,360,720,840,1260,1680,2520,5040,7560] |
|||
done... |
|||
</pre> |
|||
=={{header|Ruby}}== |
=={{header|Ruby}}== |