Update Examples
parent
e05675fe9b
commit
aebb906dfb
28
Examples.md
28
Examples.md
@ -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>
|
||||
|
Loading…
Reference in New Issue
Block a user