Course of Raku / Advanced / More about built-in types / Integers / Exercises / Prime or not
Solution: Prime or not
Here is a possible solution to the task.
Code
say 97.is-prime;
say 91.is-prime;🦋 You can find the source code in the file prime-check.raku.
Output
True
FalseComments
97has no divisors other than1and itself, sois-primereturnsTrue.91looks prime but is7 × 13, sois-primereturnsFalse. The method does the factoring for you, which is the whole point of having it.
Course navigation
← Prime or not | Native types 🆕 →