Find adjacent primes which differ by a square integer: Difference between revisions
Find adjacent primes which differ by a square integer (view source)
Revision as of 19:20, 21 November 2021
, 2 years ago→{{header|Julia}}
(julia example) |
|||
Line 201:
diffs = [pri[i] - pri[i - 1] for i in 2:length(pri)]
squarediffs = sort(unique(filter(n -> n in squares, diffs)))
println("
for sq in squarediffs
i = findfirst(x -> x == sq, diffs)
Line 209:
end
squareprimegaps(1_000_000)
squareprimegaps()
</lang>{{out}}
<pre>
Square prime gaps to 1000000:
Square difference 1: 1 found. Example: (2, 3).
Square difference 4: 8143 found. Example: (7, 11).
Square difference 16: 2881 found. Example: (1831, 1847).
Square difference 36: 767 found. Example: (9551, 9587).
Square difference 64: 24 found. Example: (89689, 89753).
Square difference 100: 2 found. Example: (396733, 396833).
Square prime gaps to 10000000000:
Square difference 1: 1 found. Example: (2, 3).
|