Computer Science, asked by suhanirajak111, 1 month ago

wap to print all the Niven no.s in the range of 1 to n where n must be more than equal to 1 and less than equal to 200.​

Answers

Answered by dibyansuptnk
1

Explanation:

num = 156;  

rem = sum = 0;  

   

#Make a copy of num and store it in variable n  

n = num;  

   

#Calculates sum of digits  

while(num > 0):  

    rem = num%10;  

    sum = sum + rem;  

    num = num//10;  

   

#Checks whether the number is divisible by the sum of digits  

if(n%sum == 0):  

    print(str(n) + " is a harshad number");  

else:  

    print(str(n) + " is not a harshad number");  

Similar questions