Sum of two adjacent numbers are primes
Sum of two adjacent numbers are primes is a draft programming task. It is not yet considered ready to be promoted as a complete task, for reasons that should be found in its talk page.
- Task
Show on this page the first 20 numbers and sum of two adjacent numbers which sum is prime.
Ring
<lang ring> load "stdlibcore.ring" see "working..." + nl n = 0 num = 0
while true
n++ sum = 2*n+1 if isprime(sum) num++ if num < 21 ? "n = " + n + " sum= " + sum else exit ok ok
end
see "done..." + nl </lang>
- Output:
working... n = 1 sum= 3 n = 2 sum= 5 n = 3 sum= 7 n = 5 sum= 11 n = 6 sum= 13 n = 8 sum= 17 n = 9 sum= 19 n = 11 sum= 23 n = 14 sum= 29 n = 15 sum= 31 n = 18 sum= 37 n = 20 sum= 41 n = 21 sum= 43 n = 23 sum= 47 n = 26 sum= 53 n = 29 sum= 59 n = 30 sum= 61 n = 33 sum= 67 n = 35 sum= 71 n = 36 sum= 73 done...