This exercise is focused on the use of accumulators. Using accumulators allows you to keep a stack constant size during the recursion calls.
In this exercise, you are asked to use accumulators in order to determine if a number is prime. A prime number is a number that can be divided only by 1 and by itself (euclidean division without remainder).
Consider your code in the following template:
fun {Prime N} [YOUR CODE] end {Prime N}
Please note that 1 is not considered as a prime number ({Prime 1} == false) and that N >= 1.
PRIME
(1/1 point)
You are asked to provide the body of the Prime function.
Write the Prime function, which returns true if N is a prime number and false otherwise.
Consider the following signature:
我的答案:评分为正确!
fun {Prime N}