I am trans-compiling this Python code:
def expand_x_1(p):
ex = [1]
for i in range(p):
ex.append(ex[-1] * -(p-i) / (i+1))
return ex[::-1]
def aks_test(p):
if p < 2: return False
ex = expand_x_1(p)
ex[0] += 1
return not any(mult % p for mult in ex[0:-1])
for p in range(101):
if aks_test(p):
print(p)
Into JavaScript. Here is what I have done so far:
function expand_x_1(p){
var ex = [1];
for(i = 0; i < p; i++){
ex.push(ex[ex.length - 2] * -(p-i) / (i+1));
}
return ex.reverse();
}
function aks_test(p){
if(p < 2)
return false;
var ex = expand_x_1(p);
ex[0] += 1;
// the return part right here is what I need help with.
}
// Python equivalent of any()
function any(iterable){
for(element in iterable)
if(element)
return true;
return false;
}
I just need help converting this line of Python code into JavaScript:
return not any(mult % p for mult in ex[0:-1])
Thanks!