```
On Nov 30, 4:46 pm, "ishamid" <isha... / colostate.edu> wrote:
> [progrmming novice]

> Is there a nicer way to do this? I can't but feel that the first
> conditional is superflous and that I should be able to do it all within
> a single "while" loop.
>
> Best
> Idris

I am only as far as this problem in the book, and this was my solution
(after I saw a few ways to clean it up after looking at yours :) ).

---------------------------------------
puts 'Start year:'
ly = gets.chomp.to_i
puts 'End year:'
lye = gets.chomp.to_i
puts ''
puts 'Leap years between and including ' + ly.to_s + ' and ' + lye.to_s
+ ':'
puts '-----------------------------------------------'
puts ''

while ly <= lye
if ly%4 == 0 && (ly%100 != 0 || ly%400 == 0)
puts ly
ly = (ly + 1).to_i
else
ly = (ly + 1).to_i
end
end
-----------------------------------------

Hope that helps.  I was looking around for help originally and all the
postings I had seen used coding that was more advanced than this
chapter of the book, so they weren't much help to check/refine my
answer.  This is a great book so far, tho, I'm really enjoying it.

Winter

```