Skip to content

Instantly share code, notes, and snippets.

@leoshimo
Created July 20, 2023 14:08
Show Gist options
  • Save leoshimo/9dbcc5c4f77b36717182f4e9425254c6 to your computer and use it in GitHub Desktop.
Save leoshimo/9dbcc5c4f77b36717182f4e9425254c6 to your computer and use it in GitHub Desktop.
fn main() {
for i in 1..=100 {
match (i % 3, i % 5) {
(0, 0) => println!("CracklePop"),
(0, _) => println!("Crackle"),
(_, 0) => println!("Pop"),
_ => println!("{}", i),
};
}
}
@leoshimo
Copy link
Author

leoshimo commented Jul 20, 2023

How to run:

$ rustc cracklepop.rs && ./cracklepop

Sample Run:

$ rustc cracklepop.rs && ./cracklepop
1
2
Crackle
4
Pop
Crackle
7
8
Crackle
Pop
11
Crackle
13
14
CracklePop
16
17
Crackle
19
Pop
Crackle
22
23
Crackle
Pop
26
Crackle
28
29
CracklePop
31
32
Crackle
34
Pop
Crackle
37
38
Crackle
Pop
41
Crackle
43
44
CracklePop
46
47
Crackle
49
Pop
Crackle
52
53
Crackle
Pop
56
Crackle
58
59
CracklePop
61
62
Crackle
64
Pop
Crackle
67
68
Crackle
Pop
71
Crackle
73
74
CracklePop
76
77
Crackle
79
Pop
Crackle
82
83
Crackle
Pop
86
Crackle
88
89
CracklePop
91
92
Crackle
94
Pop
Crackle
97
98
Crackle
Pop

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment