Skip to content

Commit 6e1d188

Browse files
committed
smallest_multiple solved
1 parent 383e624 commit 6e1d188

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

smallest_multiple/Cargo.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[package]
2+
name = "smallest_multiple"
3+
version = "0.1.0"
4+
edition = "2021"
5+
6+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
7+
8+
[dependencies]

smallest_multiple/src/main.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
fn main() {
2+
println!("{}", smallest_multiple());
3+
}
4+
5+
fn smallest_multiple() -> i32 {
6+
let mut n: i32 = 20;
7+
let mut start: i32;
8+
9+
loop {
10+
start = 20;
11+
while start > 1 {
12+
if n % start != 0 {
13+
break ;
14+
}
15+
start -= 1;
16+
}
17+
if start == 1 {
18+
break ;
19+
}
20+
n += 1;
21+
}
22+
n
23+
}

0 commit comments

Comments
 (0)