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 / 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 |
Post New Answer View All Answers
swap 2 numbers without using third variable?
A routine usually part of the operation system that loads a program into memory prior to execution a) linker b) loader c) preprocessor d) compiler
Explain how can I manipulate strings of multibyte characters?
What is extern keyword in c?
Can you write a programmer for FACTORIAL using recursion?
What are the benefits of c language?
What language is c written?
What is the description for syntax errors?
p*=(++q)++*--p when p=q=1 while(q<=6)
How to write c functions that modify head pointer of a linked list?
What is spark map function?
What are two dimensional arrays alternatively called as?
a c variable cannot start with a) an alphabet b) a number c) a special symbol d) both b and c above
what do the 'c' and 'v' in argc and argv stand for?
a) Identify the following declarations. Ex. int i (integer variable) float a[l0](array of 10 real nos) int (*f())() void *f int (*f()) [] void *f int f[] [] [] char *(*f) () int (*f[]) [] float(*f) [] [] float **f int ******f