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


Please Help Members By Posting Answers For Below Questions

What is a c token and types of c tokens?

591


Why is c so powerful?

686


program to find out date after adding 31 days to a date in the month of febraury also consider the leap year

2578


How do you declare a variable that will hold string values?

670


Explain null pointer.

622






Write a code to generate a series where the next element is the sum of last k terms.

734


Are c and c++ the same?

627


What is the size of enum in c?

620


What is the difference between strcpy() and memcpy() function in c programming?

626


What tq means in chat?

582


Explain how do you use a pointer to a function?

640


Do you know the difference between malloc() and calloc() function?

614


How do I convert a string to all upper or lower case?

629


Explain the use of fflush() function?

626


What are volatile variables in c?

520