|
|
|
|
|
by Aken
371 days ago
|
|
> If you don't know any array languages, it might explode your brain. Use at your own risk! I've been around the block, don't think it'll be a problem picking up something new > Here is a program that checks whether a number x is prime (for x>2): {&/x!:\2+!_x^1%2} (closes laptop and goes outside) |
|
You just go right to left. 1/2 applied to x^ so x^(0.5), _ is floor so floor of x^0.5. ! creates an array of numbers up until floor of x^0.5. 2+ just adds 2 to every number, and then I lost interest in learning the rest lol.
Yeah I like the python equivalent def is_prime(x): return x > 1 and all(x % i != 0 for i in range(2, x))