Cullen and Woodall numbers: Difference between revisions
Content deleted Content added
Thundergnat (talk | contribs) m Make clear the oeis links |
|||
Line 40:
=={{header|Julia}}==
<lang julia>using Lazy
using Primes
cullen(n, two = BigInt(2)) = n * two^n + 1
woodall(n, two = BigInt(2)) = n * two^n - 1
primecullens = @>> Lazy.range() filter(n -> isprime(cullen(n)))
primewoodalls = @>> Lazy.range() filter(n -> isprime(woodall(n)))
#primewoodalls(n)
println("First 20 Cullen numbers: ( n × 2**n + 1)\n", [cullen(n, 2) for n in 1:20]) # A002064
println("First 20 Woodall numbers: ( n × 2**n - 1)\n", [woodall(n, 2) for n in 1:20]) # A003261
println("\nFirst 5 Cullen primes: (in terms of n)\n", take(5, primecullens)) # A005849
println("\nFirst 12 Woodall primes: (in terms of n)\n", Int.(collect(take(12, primewoodalls)))) # A002234
</lang>{{out}}
<pre>
First 20 Cullen numbers: ( n × 2**n + 1)
[3, 9, 25, 65, 161, 385, 897, 2049, 4609, 10241, 22529, 49153, 106497, 229377, 491521, 1048577, 2228225, 4718593, 9961473, 20971521]
First 20 Woodall numbers: ( n × 2**n - 1)
[1, 7, 23, 63, 159, 383, 895, 2047, 4607, 10239, 22527, 49151, 106495, 229375, 491519, 1048575, 2228223, 4718591, 9961471, 20971519]
First 5 Cullen primes: (in terms of n)
List: (1 141 4713 5795 6611)
First 12 Woodall primes: (in terms of n)
[2, 3, 6, 30, 75, 81, 115, 123, 249, 362, 384, 462]
</pre>
|