Summarize primes: Difference between revisions
Content deleted Content added
→{{header|ALGOL 68}}: Small change so it can also do the "Prime numbers p which sum of prime numbers less or equal to p is prime" task |
m Forth - faster without using a sieve |
||
Line 448:
=={{header|Forth}}==
{{works with|Gforth}}
<lang forth>: prime? ( n --
dup 2 < if drop false exit then
dup 2 mod 0= if 2 = exit then
dup 3 mod 0= if 3 = exit then
n 4 > if▼
▲ 3
begin
while
2dup mod 0= if 2drop false exit then
2 +
2dup mod 0= if 2drop false exit then
repeat
: main
0 0 { count sum }
." count prime sum" cr
1000 2 do
i prime? if
|