Skip to content

Commit

Permalink
This plus prev commit goes 25m -> 12.5 (-50%)
Browse files Browse the repository at this point in the history
The lesson here is that while you *can* user iterators
for everything, you probably shouldn't
  • Loading branch information
LivInTheLookingGlass committed Jul 27, 2024
1 parent 98cb62f commit 7e91caf
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions c/p0012.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ divisors?

unsigned long long p0012() {
unsigned long long current = 1;
for (unsigned int i = 2; ; ++i) {
unsigned int i = 2;
while (true) {
current += i; // 3, 21, ...
++i;
current += i; // 6, 28, ...
// printf("%llu\n", current);
if (proper_divisor_count(current) > 500)
return current;
++i;
Expand All @@ -46,6 +46,7 @@ unsigned long long p0012() {
return current;
++i;
current += i; // 15, 45, ...
++i;
}
return -1;
}
Expand Down

0 comments on commit 7e91caf

Please sign in to comment.