complexpr/examples/prime.cxpr

8 lines
219 B
Text

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