Increasing gaps between consecutive Niven numbers: Difference between revisions

Content added Content deleted
m (→‎{{header|Wren}}: Minor correction to preamble.)
m (Minor edit to C code)
Line 42: Line 42:
// Returns the sum of the digits of n given the
// Returns the sum of the digits of n given the
// sum of the digits of n - 1
// sum of the digits of n - 1
uint64_t digit_sum(uint64_t n, int sum) {
uint64_t digit_sum(uint64_t n, uint64_t sum) {
++sum;
++sum;
while (n > 0 && n % 10 == 0) {
while (n > 0 && n % 10 == 0) {
Line 60: Line 60:
setlocale(LC_ALL, "");
setlocale(LC_ALL, "");


uint64_t previous = 1, gap = 0;
uint64_t previous = 1, gap = 0, sum = 0;
int niven_index = 0, gap_index = 1, sum = 0;
int niven_index = 0, gap_index = 1;


printf("Gap index Gap Niven index Niven number\n");
printf("Gap index Gap Niven index Niven number\n");