I'm basically curious into how to add up the sums of digits of an integer.
I wa wondering if the sum_two and the part to follow will work.
Would i have to put int two = (sin.charAt(1)-48)*2.
Thanks.
P.S Sorry if this is unclear
~Caceres
Sponsor Sponsor
wtd
Posted: Wed Jul 12, 2006 11:30 pm Post subject: (No subject)
There's a mathematical way of doing this. Since I don't like just giving out easy answers...
code:
(define (sum-digits n)
(if (= n 0)
0
(+ (remainder n 10)
(sum-digits (floor (/ n 10))))))
Caceres
Posted: Thu Jul 13, 2006 10:13 pm Post subject: (No subject)
For my previous code. It keeps saying
Quote:
int cannot be dereference
Anyone know what this means?
Caceres
Posted: Thu Jul 13, 2006 10:28 pm Post subject: (No subject)
For my previous code. It keeps saying
Quote:
int cannot be dereference
Anyone know what this means?
[Gandalf]
Posted: Thu Jul 13, 2006 11:00 pm Post subject: (No subject)
It means that an int is not an object, and therefore cannot be treated as such. An Integer, however...