From: ishamid Date: 2006-12-01T10:15:08+09:00 Subject: Re: loops and branching Thank you, but the following does not work properly: ================ puts 'Type initial year:' leapi = gets.chomp.to_i puts 'Type final year:' leapf = gets.chomp.to_i puts '' while (leapi + (4 - leapi%4)) <= leapf leapi = (leapi + (4 - leapi%4)) (leapi..leapf).select do |x| (x % 4 == 0) && (x % 100 != 0) || (x % 400 == 0) puts leapi end end ================ Please advise ;-) Best and Thnx Idris On Nov 30, 3:11 pm, "Christoffer Sawicki" wrote: > > if leapi%4 == 0 && (leapi%400 == 0 || leapi%100 != 0) > > puts leapi > > else > > end > > > while (leapi + (4 - leapi%4)) <= leapf > > leapi = (leapi + (4 - leapi%4)) > > if leapi%4 == 0 && (leapi%400 == 0 || leapi%100 != 0) > > puts leapi > > else > > end > > end(leapi..leapf).select do |x| > (x % 4 == 0) && (x % 100 != 0) || (x % 400 == 0) > end > > -- > Christoffer Sawickihttp://vemod.net/