niven numbers are positive integers greater than 0 that are divisoble by the
sum of theor digits for example 42 is a niven number it is divisible by 4+2=6
you are given a fumnction int checknivennumber(int n); the function accepts
an integer n as its argument implement the function to check if n is niven if n
niven then return the number of times it is dividible by the sum of its digits i.e
is the quotient else return O assume n >O input 36 output 4 input is 57 output
is?
Answers
Answered by
0
Explanation:
the output is 4 since 3+6=9 and 36/9=4
Answered by
0
Answer:
Explanation:
// Python program for Niven Number
num = int(input())
rem = sum = 0
// Making a copy of num and store it in variable n
n = num
// Calculating sum of digits
def checknivennumber(num):
while(num > 0):
rem = num%10
sum = sum + rem
num = num/10
// Checking whether the number is divisible by the sum of digits
if(n%sum == 0):
return(n/sum);
else:
return(0)
print(checknivennumber(num))
#SPJ3
Similar questions