0
PYTHON PROGRAM- REPEAT
Write a Python program to add the digits of a positive integer repeatedly until the result has a single digit. Input Format: The first line of the input contains a number n. Output: Print the resultant number Example: Input: 48 Output: 3 Explanation: If you add digits 4 and 8, you will get 12. Again adding 1 and 2 will give 3 which is a single digit and hence the answer.
1 Resposta
- 1
Write a Python program to add the digits of a positive integer repeatedly until the result has a single digit.
Input Format:
The first line of the input contains a number n.
Output:
Print the resultant number
Example:
Input:
48
Output:
3
Explanation: If you add digits 4 and 8, you will get 12. Again adding 1 and 2 will give 3 which is a single digit and hence the answer.