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 do you mean by recursion in c?
What is a pointer value and address in c?
How to create struct variables?
What are the advantages of c preprocessor?
What is extern storage class in c?
What is oops c?
The % symbol has a special use in a printf statement. How would you place this character as part of the output on the screen?
What is the difference between fread and fwrite function?
5 Write an Algorithm to find the maximum and minimum items in a set of ānā element.
Why are all header files not declared in every c program?
What is double pointer in c?
What is sizeof int in c?
swap 2 numbers without using third variable?
Is main is user defined function?
Explain how can I write functions that take a variable number of arguments?