Mode:
Duration:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
class
PRIME_CHECKER
feature
is_prime (n: INTEGER): BOOLEAN
local i: INTEGER
do
from i := 2 until i >= n loop
if n \ i = 0 then
Result := False
return
end
i := i + 1
end
Result := True
end
end
! Run
local
p: PRIME_CHECKER
num: INTEGER
do
num := 13
create p
if p.is_prime(num) then
io.put_string ("Prime"); io.put_new_line
else
io.put_string ("Not Prime"); io.put_new_line
end
endCoding works best on desktop or with an external keyboard.