PROBLEM LINK:
Author: Neeraj
Tester: Sumit
Editorialist: Manish
DIFFICULTY:
EASY.
PREREQUISITES:
Math, Bit.
PROBLEM:
Manish loves solving mathematical problems. So, one day his professor gave him an interesting problem to solve. His professor gave him a number n and Manish need to do the following operation:-
Find the sum of the digits of n. Let the sum be m. If m contains only one digit than stop! , else assign the value of m to n. Also not be a multiple of 9. If so then print 0.
Manish is required to perform the above operations until n is reduced to a single digit. Manish need to tell what that single digit will be.
As the question is a little tricky, he needs your help. Help Manish to find that single digit.
SOLUTIONS:
Setter's Solution
indent whole code by 4 spaces
Tester's Solution
indent whole code by 4 spaces
Editorialist's Solution
#include <iostream>
using namespace std;
int main() {
int t;
cin >> t;
while(t–){
unsigned long long n;
cin >> n;
int result = n%9;
cout << result << endl;
}
return 0;
}