Jump to content

Erdős-primes: Difference between revisions

add SETL
(Add Miranda)
(add SETL)
Line 1,797:
</pre>
 
=={{header|SETL}}==
<syntaxhighlight lang="setl">program erdos_primes;
loop for e in [1..2499] | erdos e do
nprint(lpad(str e, 6));
if (n +:= 1) mod 10=0 then print; end if;
end loop;
 
print;
print("There are " + str n + " Erdos numbers < 2500");
 
e := 2499;
loop while n < 7875 do
loop until erdos e do
e +:= 2;
end loop;
n +:= 1;
end loop;
 
print("The " + str n + "th Erdos number is " + str e);
 
op erdos(p);
return prime p and not exists k in faclist p | prime (p-k);
end erdos;
 
op faclist(n);
f := 1;
return [[i+:=1, f*:=i](2) : until n<f](..i-1);
end op;
 
op prime(n);
if n<=4 then
return n in [2,3];
end if;
return odd n and not exists d in [3, 5..floor (sqrt n)] | n mod d=0;
end op;
end program;</syntaxhighlight>
{{out}}
<pre> 2 101 211 367 409 419 461 557 673 709
769 937 967 1009 1201 1259 1709 1831 1889 2141
2221 2309 2351 2411 2437
There are 25 Erdos numbers < 2500
The 7875th Erdos number is 999721</pre>
=={{header|Sidef}}==
<syntaxhighlight lang="ruby">func is_erdos_prime(p) {
2,114

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.