fn main() {
let mut s: [i32; 100] = [0; 100];
let mut i = 1;
s[0] = 2;
let mut n = 3;
let mut j = 0;
while n <= 100 {
let quotient = n / s[j];
let reminder = n % s[j];
if reminder == 0 {
n = n + 2;
j = 1;
} else {
if quotient >= s[j] {
j += 1;
} else {
s[j] = n;
i += 1;
j = 1;
n = n + 2;
}
}
}
let mut i = 0;
while s[i] != 0 {
println!("{}", s[i]);
i += 1;
}
}
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.40s
Running `target/debug/basic`
thread ‘main’ panicked at src/main.rs:11:22:
attempt to divide by zero
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
整数を”0″で割るとundefinedでエラーになる。。。
うーん どう表現したら良いんやろうか