# p6c test

Perl 6 is coming, but before it runs in production it have to be fast.

This simple programme in Perl 6 checks whether the given number is prime (the number is prime when you can evenly divide it by 1 and itself only). The algorithm is immanently ineffective, as it starts to test all the numbers below the given one until it finds the one which is the divider. More sophisticated approaches should check at least if the number ends with 1, 3, 7 or 9, and may stop after reaching the square root of $n.

But for the demonstration purposes the ineffectiveness is very desired. We can see how fast is the implementation of Perl 6 machine.

say is_prime(@*ARGS[0]); sub is_prime($n) { for 2 .. $n - 1 -> $d { return 0 unless $n % $d; } return 1; }

Here is an interface to the programme. You may enter any integer number greater that 1 and see if it is a prime number. The maximum accepted number is two million. The list of primes number can be found at shitov.ru/temp/primes.