RosettaCodeData/Task/Magnanimous-numbers/BASIC256/magnanimous-numbers.basic
2023-07-01 13:44:08 -04:00

32 lines
502 B
Text

#include "isprime.kbs"
dim magn(400)
n = 10
for i = 0 to 9
magn[i] = i #all single digit ints are magnanimous by definition
next i
while i < 400
n += 1
ns = string(n)
for j = 1 to length(ns)-1
lefty = left(ns, j)
righty = right(ns, length(ns)-j)
if not isPrime(int(lefty) + int(righty)) then continue while
next j
magn[i] = n
i += 1
end while
for i = 0 to 44
print i+1, magn[i]
next i
for i =240 to 249
print i+1, magn[i]
next i
for i = 390 to 399
print i+1, magn[i]
next i
end