Pernicious numbers: Difference between revisions
Content added Content deleted
(Updated to work with Nim 1.4: added missing parameter type.) |
|||
Line 1,497: | Line 1,497: | ||
<lang nim>import strutils |
<lang nim>import strutils |
||
proc count(s: string |
proc count(s: string; sub: char): int = |
||
var i = 0 |
var i = 0 |
||
while true: |
while true: |
||
Line 1,506: | Line 1,506: | ||
inc result |
inc result |
||
proc popcount(n): int = n.toBin(64).count('1') |
proc popcount(n: int): int = n.toBin(64).count('1') |
||
const primes = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61} |
const primes = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61} |
||
var p |
var p: seq[int] |
||
var i = 0 |
var i = 0 |
||
while p.len < 25: |
while p.len < 25: |