Skip to content

Instantly share code, notes, and snippets.

@ncaq
Created October 3, 2017 10:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ncaq/b3c694957206ee2a1ed52f4c197b2b5d to your computer and use it in GitHub Desktop.
Save ncaq/b3c694957206ee2a1ed52f4c197b2b5d to your computer and use it in GitHub Desktop.
[FizzBuzz を無駄にベンチマークしてみた By Nim、golang、Rust、Crystal、その他 - 強まっていこう]: http://wolfbash.hateblo.jp/entry/2017/07/25/232027 を見て高速化させてみました
fn main() {
let mut s = String::new();
for i in 1..600000 {
if i % 3 == 0 && i % 5 == 0 {
s += "FizzBuzz\n";
} else if i % 3 == 0 {
s += "Fizz\n";
} else if i % 5 == 0 {
s += "Buzz\n";
} else {
s += i.to_string().as_str();
s += "\n";
}
}
print!("{}", s);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment