add lila source example files
This commit is contained in:
13
examples/syracuse.lila
Normal file
13
examples/syracuse.lila
Normal file
@@ -0,0 +1,13 @@
|
||||
// Computes the syracuse sequence with the given inital term
|
||||
// until it reaches 1 (it probably will).
|
||||
fn syracuse(x0: int) int {
|
||||
x = x0;
|
||||
while x != 1 {
|
||||
if x % 2 == 0 {
|
||||
set x = x / 2;
|
||||
} else {
|
||||
set x = 3 * x + 1;
|
||||
};
|
||||
};
|
||||
x
|
||||
}
|
||||
Reference in New Issue
Block a user