-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprojectRust.rs
More file actions
33 lines (25 loc) · 1.07 KB
/
projectRust.rs
File metadata and controls
33 lines (25 loc) · 1.07 KB
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
/* Programmer: Emily Godinez-Martinez
Date: 5 / 8 / 2026
CodeDay Rust Assignment
Description: A program that takes the range of 1-100 and prints out the following depending on the divisibility of a number:
- If a number is divisible by 3, print "Fizz"
- If a number is divisible by 5, print "Buzz"
- If a number is divisible by both 3 and 5, print "FizzBuzz"
We will be using a combination of if/else statements, for loops, and the range operator for this program to work.
*/
fn main() {
// For loop
for number in 1..101 { // This range is from 1-100, since 101 is not included in the range
println!("{}", number); // Prints out the number by default
// If/else statements
if number % 15 == 0 { // The same as number being divisible by 3 and 5
println!("fizzbuzz");
}
else if number % 3 == 0 { // If it wasn't divisible by both 5 and 3, but instead just 3
println!("fizz");
}
else if number % 5 == 0 { // If it wasn't divisible by both, nor 3, but instead just 5
println!("buzz");
}
}
}