Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
28
Task/Additive-primes/BASIC256/additive-primes.basic
Normal file
28
Task/Additive-primes/BASIC256/additive-primes.basic
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
print "Prime", "Digit Sum"
|
||||
for i = 2 to 499
|
||||
if isprime(i) then
|
||||
s = digSum(i)
|
||||
if isPrime(s) then print i, s
|
||||
end if
|
||||
next i
|
||||
end
|
||||
|
||||
function isPrime(v)
|
||||
if v < 2 then return False
|
||||
if v mod 2 = 0 then return v = 2
|
||||
if v mod 3 = 0 then return v = 3
|
||||
d = 5
|
||||
while d * d <= v
|
||||
if v mod d = 0 then return False else d += 2
|
||||
end while
|
||||
return True
|
||||
end function
|
||||
|
||||
function digsum(n)
|
||||
s = 0
|
||||
while n
|
||||
s += n mod 10
|
||||
n /= 10
|
||||
end while
|
||||
return s
|
||||
end function
|
||||
Loading…
Add table
Add a link
Reference in a new issue