Rhonda numbers: Difference between revisions

Replaced "isOdd" with "isEven".
(Created Nim solution.)
(Replaced "isOdd" with "isEven".)
Line 1,599:
type Base = 2..36
 
template isOddisEven(n: int): bool = (n and 1) == 0
 
func isPrime(n: Natural): bool =
## Return true if "n" is prime.
if n < 2: return false
if n.isOddisEven: return n == 2
if n mod 3 == 0: return n == 3
var d = 5
Line 1,623:
## Return the sum of prime factors of "n".
var n = n.Natural
while n.isOddisEven:
inc result, 2
n = n shr 1
256

edits