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

Answers were Sorted based on User's Feedback



Given a number N, product(N) is the product of the digits of N. We can then form a sequence N, prod..

Answer / vivekamr91

#include<stdio.h>
int main()
{
int s,sum;
long num;
printf("enter the no:");
scanf("%ld",&num);
sum=num;
while(sum>10)
{
sum=0;
while(num!=0)
{
s=num%10;
sum=sum+s;
num=num/10;
}
num=sum;
}
printf("the single digit sum is :%d",sum);
return 0;
}

Is This Answer Correct ?    2 Yes 1 No

Given a number N, product(N) is the product of the digits of N. We can then form a sequence N, prod..

Answer / 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

More C Interview Questions

how can use subset in c program and give more example

0 Answers  


write a programe to find the factorial of given number using recursion

3 Answers  


What has to put when we are inserting as assembly language code into the C code? or When we are inserting as assembly language code into the C code we have to insert one thing at the start and of the assembly language. What are they?

2 Answers  


The variables are int sum=10,SuM=20; these are same or different?

3 Answers  


Is struct oop?

0 Answers  






Combinations of fibanocci prime series

0 Answers  


Is it possible to use curly brackets ({}) to enclose single line code in c program?

0 Answers  


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

0 Answers   Aspiring Minds,


If null and 0 are equivalent as null pointer constants, which should I use?

0 Answers  


Explain union.

0 Answers  


#include<std.h> int main() { char *str[]={"Frogs","Do","Not","Die","They","Croak!"}; printf("%d %d\n",sizeof(str),strlen(str)); ...return 0; } what will the output of the above program?

6 Answers  


What is the best organizational structure?

0 Answers  


Categories