Two boys, Venky and Sagar, are at war over a girl, Riu. Driven by their feelings, they decided to confess to Riu. Since both of them were equally dumb, Riu decided that she would go out with that boy who would successfully find the pattern and thus prove that he is less dumb.
Example:
Input: n = 100
Output: 121
Approach
C++
#include <bits/stdc++.h>using namespace std;long long fun(long long n){if (n < 9)return n;return n % 9 + 10 * fun(n / 9);}int main(){long long n = 100;cout << fun(n) << "\n";return 0;}
No comments:
Post a Comment