Advertisement
Guest User

Untitled

a guest
Feb 15th, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.23 KB | None | 0 0
  1. Algorithm turnOn(n)
  2. //Pre-Condition: Lights 1...n are all off.
  3. //Post-Condition: Lights1...n are all on.
  4. if (n = 1) then Turn ON light 1
  5. else { //n >=2
  6.     if (n > 2) then turnOff(n-2)
  7.     if (n > 2) then turnOff(n-2)
  8. }
  9. end //turnOn
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement