Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fn one() {
- let mut count : u64 = 0;
- let until = 1e8 as u64;
- for i in 1..until {
- let s = i.to_string();
- if s.contains("3") {
- count+=1;
- }
- }
- println!("Count until {}: {}", until, count);
- }
- fn two() {
- let mut count : u64 = 0;
- let until = 1e8 as u64;
- let mut s = String::with_capacity(10);
- for i in 1..until {
- s.clear();
- use std::fmt::Write;
- write!(s, "{}", i).unwrap();
- if s.contains("3") {
- count+=1;
- }
- }
- println!("Count until {}: {}", until, count);
- }
Add Comment
Please, Sign In to add comment