Jump to content

Increasing gaps between consecutive Niven numbers: Difference between revisions

m
Minor 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 %, sum == 0)) {
if (niven > previous + gap) {
gap = niven - previous;
1,777

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.