Data update
This commit is contained in:
parent
35bcdeebf8
commit
74c69a0df6
2427 changed files with 31826 additions and 3468 deletions
28
Task/Additive-primes/MiniScript/additive-primes.mini
Normal file
28
Task/Additive-primes/MiniScript/additive-primes.mini
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
isPrime = function(n)
|
||||
if n <= 3 then return n > 1
|
||||
if n % 2 == 0 or n % 3 == 0 then return false
|
||||
|
||||
i = 5
|
||||
while i ^ 2 <= n
|
||||
if n % i == 0 or n % (i + 2) == 0 then return false
|
||||
i += 6
|
||||
end while
|
||||
return true
|
||||
end function
|
||||
|
||||
digitSum = function(n)
|
||||
sum = 0
|
||||
while n > 0
|
||||
sum += n % 10
|
||||
n = floor(n / 10)
|
||||
end while
|
||||
return sum
|
||||
end function
|
||||
|
||||
additive = []
|
||||
|
||||
for i in range(2, 500)
|
||||
if isPrime(i) and isPrime(digitSum(i)) then additive.push(i)
|
||||
end for
|
||||
print "There are " + additive.len + " additive primes under 500."
|
||||
print additive
|
||||
Loading…
Add table
Add a link
Reference in a new issue