Next: Now for Fortran
Up: CS101 Lecture 5
Previous: Top Shell
How to test if a number n has 235 property?
Repeated division by 2, 3 and 5.
Use a variable quot to keep quotient.
- Start with quot = n.
- If (quot is even) make quot = quot / 2
And keep doing the above until quot is not even!
- If (quot is divisble by 3) make quot = quot / 3
And keep doing the above until quot is not divisible by 3!
- If (quot is divisible by 5) make quot = quot / 5
And keep doing the above until quot is not divisible by 5!
- Has quot been reduced to 1? If yes, n is a 235-number,
else it is not.
G. Sivakumar
2000-08-06