Posts by Leonardo Rodrigues Dos Santos • 11 points
2 posts
-
0
votes2
answers65
viewsA: Sum of n + last digit on the left
Solution: #include <stdio.h> int somault(int n){ if(n/10 < 10) return n-n/10; return n+(n/10-somault(n/10)); } int main() { int n; scanf("%d", &n); printf("%d", somault(n)); return 0; }…
-
1
votes2
answers65
viewsQ: Sum of n + last digit on the left
I have a recursion challenge. The goal is to return "n + the sum of the last digit on the left". Example: Input: 54321 Output: 54326 (54321 + 5) But the only way I could was like this: #include…