-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathloops.rs
More file actions
44 lines (38 loc) · 884 Bytes
/
loops.rs
File metadata and controls
44 lines (38 loc) · 884 Bytes
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
// Loops - Used to iterate until a condition is met
pub fn run() {
let mut count = 0;
// Infinite Loop
// loop {
// count += 1;
// println!("Number: {}", count);
// if count == 20 {
// break;
// }
// }
// While Loop (FizzBuzz)
// while count <= 100 {
// if count % 15 == 0 {
// println!("fizzbuzz");
// } else if count % 3 == 0 {
// println!("fizz");
// } else if count % 5 == 0 {
// println!("buzz")
// } else {
// println!("{}", count);
// }
// // Inc
// count += 1;
// }
// For Range
for x in 0..100 {
if x % 15 == 0 {
println!("fizzbuzz");
} else if x % 3 == 0 {
println!("fizz");
} else if x % 5 == 0 {
println!("buzz")
} else {
println!("{}", x);
}
}
}