Update Examples

Glen Whitney 2024-08-27 05:08:16 +00:00
parent e05675fe9b
commit aebb906dfb

@ -1358,11 +1358,37 @@ fn main
<td>
```
fn main() {
fn sum_odd_numbers(up_to: u32) -> u32 {
let mut acc = 0;
for i in 0..up_to {
let addition: u32 = match i%2 == 1 {
true => i,
false => continue,
};
acc += addition;
}
acc
}
println!("Sum of odd numbers up to 9 (excluding): {}", sum_odd_numbers(9));
}
```
</td><td>
```
fn main
fn sum_odd_numbers(up_to: u32) -> u32
let mut acc = 0
for i in 0..up_to
let addition: u32 = match i%2 == 1
true => i
false => continue
acc += addition
acc
println!
"Sum of odd numbers up to 9 (excluding): {}"
sum_odd_numbers 9
```
</td></tr></table>