previous
|
index
|
next
Problem: Determine the Number of Digits in an Integer
Want a procedure
num-digits
that behaves like:
Expression
Value
(num-digits 9475)
4
(num-digits 1234567890)
10
(num-digits 0)
1
Q:
What similar, smaller problem is such that, if you had a solution to it, would make the overall problem easy?
A:
The problem of determining the number of digits in an integer that is one digit smaller.
Example:
Number of digits in
9475
=
Number of digits in
947
+
1
=
3
+
1
=
4
Q
: How can we obtain
947
from
9475
?
previous
|
index
|
next