Simon is planning to summer vacation trip to Kodaikanal. His friends Tina, Nathan, and Irfan all learned about Samson’s plan. They said, we are also coming too, but Simon has only money to spend for him alone. Simon is very good at programming, So he puts a puzzle to his friends to avoid taking them to Kodaikanal and tells them that those who finish this can come with him.

the puzzle is to find a super digit of an integer x using the following rules: For Given integers, you need to find the super digit of the integer.

If x has only 1 digit, then its super digit is x. Otherwise, the super digit of x is equal to the super digit of the sum of the digits of x.**Functional Description** For finding the digit and value, you have used the following expressions

sum+=n%10;

n/=10;**Explanation**

**super digit of 9875 will be calculated as:**

*For Example 1:*

super-digit(9875) = super-digit(9+8+7+5)

= super-digit(29)

= super-digit(2+9)

= super-digit(11)

= super-digit(1+1)

= super-digit(2)

= 2.

*Example 2 (for two numbers)*You are given two numbers n and k. The number p is created by concatenating the string n k times. Continuing the above example where n=1234, assume your value k=4.

Your initial p=1234 1234 1234 1234 (spaces added for clarity).

superDigit(p) = superDigit(123412341234234)

1+2+3+4+1+2+3+4+1+2+3+4+4+3+2+1 = 40

superDigit(p) = superDigit(40)

4+0 = 4

superDigit(p) = superDigit(4)

All of the digits of p sum to 40. The digits of 40 sum to 4.

4 is only one digit, so it’s the super digit.

**Input:
**The single line represents the integer n and k
**Output:**
single-line prints the super digit value.

#include <stdio.h> int sumd(int n) { int k, sum=0; scanf("%d", &k); while(n) { sum+=n%10; n/=10; } return sum*k; } int superd(int num) { int n=0; return (num%9 == 0) ? n = 9:num%9; } { int main() int num; scanf("%d", &num); num= sumd(num); printf("%d",superd(num)); return 0; }

**INPUT_1:**

1234 5

**OUTPUT:**

5

**INPUT_2:**9875 4

**OUTPUT:**

8

**INPUT_3:**

5689 3

**OUTPUT:**

3

**INPUT_4:**

2365 2

**OUTPUT:**

5

**ILLUSTRATION**

Morae Q!

- Find how long will it take till the next fortune year from the current year.
- Find if it’s possible to distribute all the crayons into boxes and satisfy all the conditions.
- Compute sum of numbers using call by reference.
- Compute the amount of money to be handed over with conditions.
- Find the total number of beautiful triplets in the sequence.
- Find the total amount each worker has to pay individually.
- Find the minimum distance between any pair of equal elements in the array.
- Compute the maximum possible value of the given equation.
- Find the age of the student at the time of joining.
- Compute the total number of photos at each restaurant .
- Find the sum of digits of the number using Union datatype.
- Generate the details of the novels in the expected format.
- Sort the student details based on their names in ascending order.
- Find a way to move the king from current position to different square on chessboard.
- Find the time differences in the two different time zones.
- Identifying the greatest number with a numerator and denominator.
- Find the Minimum number of packages to supply all the bases.
- Tower of Hanoi, A puzzle.
- Compute the sum of array of elements using recursion method.
- Find the super digit of an integer using the rules.