-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path066.fun
More file actions
49 lines (44 loc) · 841 Bytes
/
066.fun
File metadata and controls
49 lines (44 loc) · 841 Bytes
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# this test looks for basic functionality on the spec
# the recursion also tries confusing the compiler into messing up its registers for non-stack machines with alternating inputs
# if and while loop testing
fun prime(p) {
if(p <= 2) {
return 1
}
if(p % 2 == 0) {
return 0
}
i = 3
while((i * i) <= p) {
if(p % i == 0) {
return 0
}
i = i + 2
}
return 1
}
# recursive alternating testing
fun gcd(a, b) {
if(b == 0) {
return a
}
return gcd(b, a % b)
}
fun checkGCDPrime(a, b) {
print(a)
print(b)
g = gcd(a, b)
print(prime(g))
}
fun main() {
size = 20
x = 1
while(x <= size) {
y = x
while(y <= size) {
checkGCDPrime(x,y)
y = y + 1
}
x = x + 1
}
}