Data update

This commit is contained in:
Ingy döt Net 2023-09-16 17:28:03 -07:00
parent 5af6d93694
commit 796d366b97
455 changed files with 7413 additions and 1900 deletions

View file

@ -1,25 +1,28 @@
proc isprime x . r .
r = 1
for i = 2 to sqrt x
if x mod i = 0
r = 0
break 2
.
func prime n .
if n mod 2 = 0 and n > 2
return 0
.
i = 3
sq = sqrt n
while i <= sq
if n mod i = 0
return 0
.
i += 2
.
return 1
.
proc digsum n . sum .
sum = 0
func digsum n .
while n > 0
sum += n mod 10
n = n div 10
.
return sum
.
for i = 2 to 500
call isprime i r
if r = 1
call digsum i s
call isprime s r
if r = 1
if prime i = 1
s = digsum i
if prime s = 1
write i & " "
.
.

View file

@ -0,0 +1,17 @@
/* Function that returns a list of digits given a nonnegative integer */
decompose(num) := block([digits, remainder],
digits: [],
while num > 0 do
(remainder: mod(num, 10),
digits: cons(remainder, digits),
num: floor(num/10)),
digits
)$
/* Routine that extracts from primes between 2 and 500, inclusive, the additive primes */
block(
primes(2,500),
sublist(%%,lambda([x],primep(apply("+",decompose(x))))));
/* Number of additive primes in the rank */
length(%);