Ma figurati!! E se vuoi anche il metodo iterativo (già k ci siamo diamo il pacchetto completo![]()
)
codice:public int SommaCifre(int n) { if(n < 0) throw new IllegalArgumentException("n must be positive"); int sommaCifre = 0; while(n > 0) { sommaCifre += n; n = n / 10; } return sommaCifre; }