Scheme Exercises

back to exercise list       previous     next

Group:     Exercise: 16/48 

Multi-branch decision:  Exercise with "cond"

Create a function called "smallest-div" which will return the smallest divisor (other than 1) of any of the numbers between 2 and 10. You are guaranteed that the function will be called only with numbers in the range from 2 to 10.
For instance:
(smallest-div 4) -> 2
(smallest-div 5) -> 5
(smallest-div 6) -> 2
(smallest-div 9) -> 3