-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtesting.txt
63 lines (59 loc) · 929 Bytes
/
testing.txt
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
/*enum E {
A(i32),
B(i64),
C(i128),
}
struct X {
a: i32,
b: i32,
c: i32,
}
compound Shape {
Circle { radius: f64 },
Rect { width: f64 :: 0 < $, height: f64 :: 0 < $ }
} + {
x: f64,
y: f64,
};*/
include 'std/mod.eee';
let math = std.math;
let and = std.logic.and;
fn prime(x) {
if x == 2 {
true
} else if x < 2 {
false
} else {
let k = 2;
let max = math.sqrt(x) + 1;
let has_div = false;
while and(k < max, !has_div) {
if math.mod(x, k) == 0 {
has_div = true
};
k += 1
};
!has_div
}
};
let i = 0;
while i < 10000 {
i += 1;
if prime(i) {
show i
}
}
/*fn fib(x) {
if x <= 0 {
0
} else if x == 1 {
1
} else {
fib(x - 1) + fib(x - 2)
}
};
let i = 0;
while i < 100 {
show fib(i);
i += 1
}*/