Primes whose sum of digits is 25: Difference between revisions
Content deleted Content added
MaiconSoft (talk | contribs) Added Delphi example |
|||
Line 161: | Line 161: | ||
load "stdlib.ring" |
load "stdlib.ring" |
||
see "working..." + nl |
|||
decimals(0) |
|||
row = 0 |
row = 0 |
||
num = 0 |
|||
nr = 0 |
|||
limit1 = 25 |
limit1 = 25 |
||
limit2 = 5000 |
limit2 = 5000 |
||
Line 177: | Line 181: | ||
ok |
ok |
||
next |
next |
||
see nl + "Found " + row + " sum25 primes below 5000" + nl |
|||
time1 = clock() |
|||
see nl |
|||
row = 0 |
|||
while true |
|||
num = num + 1 |
|||
str = string(num) |
|||
for m = 1 to len(str) |
|||
if str[m] = 0 |
|||
loop |
|||
ok |
|||
next |
|||
if isprime(num) |
|||
bool = sum25(num) |
|||
if bool = 1 |
|||
nr = nr + 1 |
|||
ok |
|||
ok |
|||
time2 = clock() |
|||
time3 = (time2-time1)/1000/60 |
|||
if time3 > 30 |
|||
exit |
|||
ok |
|||
end |
|||
see "There are " + nr + " sum25 primes that contain no zeroes" + nl |
|||
see "time = " + time3 + " mins" + nl |
|||
see "done..." + nl |
|||
func sum25(n) |
func sum25(n) |
||
Line 190: | Line 225: | ||
{{out}} |
{{out}} |
||
<pre> |
<pre> |
||
working... |
|||
997 1699 1789 1879 1987 |
997 1699 1789 1879 1987 |
||
2689 2797 2887 3499 3697 |
2689 2797 2887 3499 3697 |
||
3769 3877 3967 4597 4759 |
3769 3877 3967 4597 4759 |
||
4957 4993 |
4957 4993 |
||
Found 17 sum25 primes below 5000 |
|||
There are 1555 sum25 primes that contain no zeroes |
|||
time = 30 mins |
|||
done... |
|||
</pre> |
</pre> |