Computer Science, asked by harisiva, 1 year ago

In recreational mathematics, a Niven number in a given number base, is an integer that is divisible by the sum of its digits when written in that base. For example, in base 10, 18 is a Niven number since 18 is divisible by 1+8 = 9. Also, 12001 in base 3 is also a Niven number since the sum of the digits is 4 (which is 11 in base 3) divides 12001 (12001 = 1021 x 11).

Given a base b, any number n < b is trivially a Niven number. We will ignore this case.

Given a base b, and a positive integer T, find the lowest number L such that L, L+1, ..., L+T-1 are all Niven numbers but neither L-1 nor L+T are Niven numbers.

Answers

Answered by abdulrehman310otuf2h
1
#include <stdio.h>
#include <stdlib.h>

int main(void)
{
int n,d,a,sum=0;
printf("\n Enter the number :");
scanf("%d",&n);
a=n;
while(a>0)
{
d=a%10;
sum=sum+d;
a=a/10;
}
if(n%sum==0)
printf("\n The number is Harshard Number");
else
printf("\n The number is not a Harshard Number");
getch();
    return 0;
}


Similar questions