JavaScript (ES7), 64(削除) 64 (削除ここまで) 58 bytes
a=>(g=d=>n%g=d=>a+a?n%--d?g(d):d<2?n**a(d>1||n**a.shift()*(a+a?g)*g(++n):1):g(++n))(n=2)
With BigInts, 6561 bytes
a=>(g=d=>n%g=d=>a+a?n%--d?g(d):(d<2?d:n**a.shift()*(a+a?g(++n):d):g*g(++n):1n)(n=2n)
a => ( // a[] = input array
g = d => // g is a recursive function taking a divisor d
a + a ? // if a[] is not empty:
n % --d ? // decrement d; if it's not a divisor of n:
g(d) // do recursive calls until it is
: // else:
d < 2 ? // if d( is less than 2 (n is prime):
n ** a.shift() // multiply the final result by:
n to the power
d > 1 || // - 1 //if d is greater than of1 the(n nextis exponentcomposite)
extracted from a[]
n *** a.shift() // - the prime n raised to //the power of the next
and multiply by:
) a + a ? // ifexponent a[]extracted isfrom nota[] empty:otherwise
* g(++n) // and multiply by the result of a recursive call with n + 1
: // else:
1 // with n just+ 1
) //
: : // else (n is composite):
1 g(++n) // return the result// of a recursivestop callthe withrecursion nand +return 1
)(n = 2) // initial call to g with d = n = 2
JavaScript (ES7), 64 bytes
a=>(g=d=>n%--d?g(d):d<2?n**a.shift()*(a+a?g(++n):1):g(++n))(n=2)
With BigInts, 65 bytes
a=>(g=d=>n%--d?g(d):d<2?n**a.shift()*(a+a?g(++n):d):g(++n))(n=2n)
a => ( // a[] = input array
g = d => // g is a recursive function taking a divisor d
n % --d ? // decrement d; if it's not a divisor of n:
g(d) // do recursive calls until it is
: // else:
d < 2 ? // if d is less than 2 (n is prime):
n ** a.shift() // multiply the final result by n to the power
// of the next exponent extracted from a[]
* ( // and multiply by:
a + a ? // if a[] is not empty:
g(++n) // the result of a recursive call with n + 1
: // else:
1 // just 1
) //
: // else (n is composite):
g(++n) // return the result of a recursive call with n + 1
)(n = 2) // initial call to g with d = n = 2
JavaScript (ES7), (削除) 64 (削除ここまで) 58 bytes
a=>(g=d=>a+a?n%--d?g(d):(d>1||n**a.shift())*g(++n):1)(n=2)
With BigInts, 61 bytes
a=>(g=d=>a+a?n%--d?g(d):(d<2?d:n**a.shift())*g(++n):1n)(n=2n)
a => ( // a[] = input array
g = d => // g is a recursive function taking a divisor d
a + a ? // if a[] is not empty:
n % --d ? // decrement d; if it's not a divisor of n:
g(d) // do recursive calls until it is
: // else:
( // multiply the final result by:
d > 1 || // - 1 if d is greater than 1 (n is composite)
n ** a.shift() // - the prime n raised to the power of the next
) // exponent extracted from a[] otherwise
* g(++n) // and multiply by the result of a recursive call
// with n + 1
: // else:
1 // stop the recursion and return 1
)(n = 2) // initial call to g with d = n = 2
JavaScript (Node.js) , 65 bytes
With BigInts, 65 bytes
Commented
a => ( // a[] = input array
g = d => // g is a recursive function taking a divisor d
n % --d ? // decrement d; if it's not a divisor of n:
g(d) // do recursive calls until it is
: // else:
d < 2 ? // if d is less than 2 (n is prime):
n ** a.shift() // multiply the final result by n to the power
// of the next exponent extracted from a[]
* ( // and multiply by:
a + a ? // if a[] is not empty:
g(++n) // the result of a recursive call with n + 1
: // else:
1 // just 1
) //
: // else (n is composite):
g(++n) // return the result of a recursive call with n + 1
)(n = 2) // initial call to g with d = n = 2
JavaScript (Node.js) , 65 bytes
With BigInts, 65 bytes
Commented
a => ( // a[] = input array
g = d => // g is a recursive function taking a divisor d
n % --d ? // decrement d; if it's not a divisor of n:
g(d) // do recursive calls until it is
: // else:
d < 2 ? // if d is less than 2 (n is prime):
n ** a.shift() // multiply the final result by n to the power
// of the next exponent extracted from a[]
* ( // and multiply by:
a + a ? // if a[] is not empty:
g(++n) // the result of a recursive call with n + 1
: // else:
1 // just 1
) //
: // else (n is composite):
g(++n) // return the result of a recursive call with n + 1
)(n = 2) // initial call to g with d = n = 2
JavaScript (ES7), 64 bytes
a=>(g=d=>n%--d?g(d):d<2?n**a.shift()*(a+a?g(++n):1):g(++n))(n=2)
JavaScript (Node.js) , 65 bytes
A version that supports large integers. Expects a list of BigInts.
a=>(g=d=>n%--d?g(d):d<2?n**a.shift()*(a+a?g(++n):d):g(++n))(n=2n)
JavaScript (ES7), 64 bytes
a=>(g=d=>n%--d?g(d):d<2?n**a.shift()*(a+a?g(++n):1):g(++n))(n=2)
JavaScript (ES7), 64 bytes
a=>(g=d=>n%--d?g(d):d<2?n**a.shift()*(a+a?g(++n):1):g(++n))(n=2)
JavaScript (Node.js) , 65 bytes
A version that supports large integers. Expects a list of BigInts.
a=>(g=d=>n%--d?g(d):d<2?n**a.shift()*(a+a?g(++n):d):g(++n))(n=2n)