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