18 lines
304 B
C
18 lines
304 B
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
|
|
uint rec(uint acc, uint x) {
|
|
if (x < 10) {
|
|
return acc + x;
|
|
} else {
|
|
return rec(acc + (x % 10), x / 10);
|
|
}
|
|
}
|
|
|
|
int f(uint x) { return rec(0, x); }
|
|
|
|
int main() {
|
|
int x = 3459023;
|
|
printf("Somme des chiffres de %d : %d", x, f(x));
|
|
}
|