Anti-primes: Difference between revisions
Content deleted Content added
Add Seed7 example. |
|||
Line 1,193: | Line 1,193: | ||
<pre>The first 20 anti-primes are: |
<pre>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 </pre> |
1 2 4 6 12 24 36 48 60 120 180 240 360 720 840 1260 1680 2520 5040 7560 </pre> |
||
=={{header|Seed7}}== |
|||
<lang seed7>$ include "seed7_05.s7i"; |
|||
const func integer: countDivisors (in integer: number) is func |
|||
result |
|||
var integer: count is 1; |
|||
local |
|||
var integer: num is 0; |
|||
begin |
|||
for num range 1 to number div 2 do |
|||
if number rem num = 0 then |
|||
incr(count); |
|||
end if; |
|||
end for; |
|||
end func; |
|||
const proc: main is func |
|||
local |
|||
var integer: maxDiv is 0; |
|||
var integer: count is 0; |
|||
var integer: number is 1; |
|||
var integer: divisors is 1; |
|||
begin |
|||
writeln("The first 20 anti-primes are:"); |
|||
while count < 20 do |
|||
divisors := countDivisors(number); |
|||
if divisors > maxDiv then |
|||
write(number <& " "); |
|||
maxDiv := divisors; |
|||
incr(count); |
|||
end if; |
|||
incr(number); |
|||
end while; |
|||
writeln; |
|||
end func;</lang> |
|||
{{out}} |
|||
<pre>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 |
|||
</pre> |
|||
=={{header|Sidef}}== |
=={{header|Sidef}}== |