Given a number N, product(N) is the product of the digits of
N. We can then form a sequence N, product(N),
product(product(N))… For example, using 99, we get the
sequence 99, 99 = 81, 81 = 8.
Input Format:
A single integer N
Output Format:
A single integer which is the number of steps after which a
single digit number occurs in the sequence.
Sample Test Cases:
Input #00:
99
Output #00:
2
Explanation:
Step - 1 : 9 * 9 = 81
Step - 2 : 8 * 1 = 8
There are 2 steps to get to this single digit number.
Input #01:
1137638147
Answer Posted / tuhin banerjee
#include<stdio.h>
int main()
{
int s,mul;
long num;
int count =0;
printf("enter the no:");
scanf("%ld",&num);
mul=num;
while(mul>10)
{
mul=1;
while(num!=0)
{
s=num%10;
mul=mul*s;
num=num/10;
}
num=mul;
count++;
}
printf("the single digit sum is :%d",mul);
printf("the single digit answer is :%d",count);
return 0;
}
Is This Answer Correct ? | 0 Yes | 2 No |
Post New Answer View All Answers
What is a c token and types of c tokens?
Why is c so powerful?
program to find out date after adding 31 days to a date in the month of febraury also consider the leap year
How do you declare a variable that will hold string values?
Explain null pointer.
Write a code to generate a series where the next element is the sum of last k terms.
Are c and c++ the same?
What is the size of enum in c?
What is the difference between strcpy() and memcpy() function in c programming?
What tq means in chat?
Explain how do you use a pointer to a function?
Do you know the difference between malloc() and calloc() function?
How do I convert a string to all upper or lower case?
Explain the use of fflush() function?
What are volatile variables in c?