Prova con:
Codice PHP:/*
* Compiled and tested with:
* i686-apple-darwin8-gcc-4.0.1 (GCC) 4.0.1 (Apple Computer, Inc. build 5367)
*
* input: 65536
* output: 7
*
*/
#include <stdio.h>
#include <stdlib.h>
int somma(int);
int main() {
int a;
scanf("%i",&a);
printf("%i\n",somma(a));
return 0;
}
int somma(int n) {
if (n < 10)
return n;
else
n = somma (n%10 + somma(n/10));
return n;
}

Rispondi quotando