-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path058.fun
More file actions
114 lines (105 loc) · 1.6 KB
/
058.fun
File metadata and controls
114 lines (105 loc) · 1.6 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# This tests #dealing with ##many parameters and #values
fun f1(p1, p2,p3, p4, p5, p6, p7,p8,p9,p10)
{
if(p1 == 0)
{
print(p1+p2+p3+p4+p5+p6+p7+p8+p9+p10)
}
a=1
b=2
c=3
d=4
e=5
f=6
g=7
h=8
i=9
print(i-h+g-f+e-d+c-b+a)
}
# Tests if and whiles within functions
fun f2()
{
i = 1
while(i > 10)
{
i = i / 10
}
while(i < 10)
{
i = i + 1
}
if(i != 10)
{
return 0 + 1
}
else
{
return 10 - 1
}
}
#Tests functions calling other functions, simple operations, and local variables with the same name as those in other functions
fun f3()
{
a = f1(0,10 ,10,10,10,10,10,10,10,11)
print(a)
a = 101
print(a+2)
print(a-2)
print(a*2)
print(a/2)
print(a%2)
print(a&&2)
print(!a)
print(!a&&2)
print(a||2)
print(a < 2)
print(!a < 2)
print(a <= 2)
print(a > 2)
print(a >= 2)
}
fun f4(v1, v2)
{
if((v1+v2)/2)
{
return v1+v2
}
}
fun fibo100(first, second)
{
if(!(first > 100 || second > 100))
{
print(first + second)
fibo100(second, first+second)
}
}
fun main()
{
print(f2())
f3()
# Test with big numbers
a = 18446744073709551615/18446744073709551615
print(a)
a = 18446744073709551615 + 1
print(a)
a = 18446744073709551615%18446744073709551615
print(a)
# Order of operations
A = 15
c = 3
orderOps1 = (((A* 2*!(0&& c) + 8)))
print(orderOps1+10)
orderOps2= ((((4))-3))
print(orderOps2)
orderOps3 = 0 || 1 && 0 != 0 <= 7-8+13%5*!0
print(orderOps3)
orderOps4 = 2*(f4(4,5) - f4(0,1)) + A
print(orderOps4)
#Bad variable names
ifValif = 10
elseValelse = 5
returnValreturn = 3
funValwhile = 2
print(ifValif + elseValelse + returnValreturn + funValwhile)
fibo100(0,1)
}