Skip to content

Instantly share code, notes, and snippets.

@BradEwing
Last active August 29, 2015 14:25
Show Gist options
  • Select an option

  • Save BradEwing/e666b6a8075639be2cfc to your computer and use it in GitHub Desktop.

Select an option

Save BradEwing/e666b6a8075639be2cfc to your computer and use it in GitHub Desktop.
// Solution to Project Euler Problem 3,
// https://projecteuler.net/problem=3
// brute force
fn main() {
let mut num = 600851475143i64;
let mut div = 2;
let mut v = vec![];
while num > 1 {
if num%div == 0 {
num = num / div;
v.push(div);
} else {
div+= 1;
}
}
println!("{:?}", v.iter().max().unwrap());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment