Files
flux/examples/fibonacci.flx
Jooris Hadeler 53c66a3d03 Feat: update VSCode extension with compound assignment and shift operators
Add compound assignment operators (+=, -=, *=, /=, %=, &=, |=, ^=,
<<=, >>=) and shift operators (<<, >>) to the tmLanguage syntax
highlighting grammar. Patterns are ordered longest-first to prevent
shorter tokens from shadowing multi-character operators. Also update
fibonacci example to use += compound assignment.
2026-03-11 10:11:01 +01:00

23 lines
358 B
Plaintext

fn fibonacci_rec(n: u8) -> u64 {
if n < 2 {
return n;
}
return fibonacci_rec(n - 1) + fibonacci_rec(n - 2);
}
fn fibonacci_iter(n: u8) -> u64 {
let mut counter = 0;
let mut a = 0;
let mut b = 1;
while counter < n {
let temp = a + b;
a = b;
b = temp;
counter += 1;
}
return a;
}