Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def appleBoxes(k)
- yellow_apples = 1
- red_apples = 0
- x = 2
- while (x <= k)
- if x % 2 != 0 then
- yellow_apples = yellow_apples + (x * x)
- end
- if x % 2 == 0 then
- red_apples = red_apples + (x * x)
- end
- x = x + 1
- end
- return red_apples - yellow_apples
- end
Advertisement
Add Comment
Please, Sign In to add comment