Skip to content

Commit

Permalink
Merge pull request #1929 from Natan7/leap_year
Browse files Browse the repository at this point in the history
Check Leap Year
  • Loading branch information
shoaibrayeen authored Oct 4, 2023
2 parents 33f9d82 + 295737f commit 74fea03
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions Basic/Check Leap Year/SolutionByNatan7.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
def check_leap_year (year)
year % 400 == 0 || (year % 4 == 0 && year % 100 != 0)
end


def check_year_number (n)
if n < 1
print("Oh, invalid year!\n")
exit
end
end

# Main
print("Enter Year: ")
year = gets.chomp.to_i
check_year_number(year)

puts check_leap_year(year)
###

0 comments on commit 74fea03

Please sign in to comment.