Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Algorithm turnOn(n)
- //Pre-Condition: Lights 1...n are all off.
- //Post-Condition: Lights1...n are all on.
- if (n = 1) then Turn ON light 1
- else { //n >=2
- if (n > 2) then turnOff(n-2)
- if (n > 2) then turnOff(n-2)
- }
- end //turnOn
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement