Skip to content

Instantly share code, notes, and snippets.

@ColemanGariety
Created April 8, 2016 23:06
Show Gist options
  • Save ColemanGariety/72e05a69bff96f5c783986df34206d47 to your computer and use it in GitHub Desktop.
Save ColemanGariety/72e05a69bff96f5c783986df34206d47 to your computer and use it in GitHub Desktop.
pub fn solve(max:u32, terms:usize) -> usize {
(1..max)
.filter(|&i| {
let mut v = Vec::with_capacity(terms);
let mut start = i;
let mut j = 0;
while !v.contains(&start) {
v.push(start);
start = digit_factorial_sum(start);
j += 1
}
return j == terms
})
.count()
}
solve(1000000, 60)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment