complexpr/examples/prime.cxpr
2022-09-20 23:38:58 -04:00

8 lines
240 B
Text

# compute the primorial of n - the product of all primes <= n
fn primorial(n) {
return 2..(n+1) |? is_prime |// fn(x,y) { return x*y; };
}
println(primorial(10)); # 2*3*5*7 = 210
println(primorial(20)); # 2*3*5*7*11*13*17*19 = 9699690