Increasing gaps between consecutive Niven numbers: Difference between revisions
Increasing gaps between consecutive Niven numbers (view source)
Revision as of 07:28, 12 May 2020
, 4 years agoMinor performance improvement
m (Minor performance improvement) |
m (Minor performance improvement) |
||
Line 36:
{{trans|C++}}
<lang c>#include <locale.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
Line 48 ⟶ 49:
}
return sum;
}
inline bool divisible(uint64_t n, uint64_t d) {
if ((d & 1) == 0 && (n & 1) == 1)
return false;
return n % d == 0;
}
Line 59 ⟶ 66:
for (uint64_t niven = 1; gap_index <= 32; ++niven) {
sum = digit_sum(niven, sum);
if (divisible(niven
if (niven > previous + gap) {
gap = niven - previous;
|