Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I am struggling to understand how the formula works and what exactly n and m are. Please assist Write a program called'firstday.py' that asks the

I am struggling to understand how the formula works and what exactly n and m are. Please assist image text in transcribed
Write a program called'firstday.py' that asks the user to enter a year range and that prints out the name of the day on which the 1st of January falls for each year in that range. Sample IO: Enter the first year: 2015 Enter the second year: 2020 The 1st of January 2015 falls on a Thursday The 1st of January 2016 falls on a Friday. The 1st of January 2017 falls on a Sunday. The 1st of January 2018 falls on a Monday. The 1st of January 2019 falls on a Tuesday. The 1st of January 2020 falls on a Wednesday. Algorithm: Given a 4 digit number representing a year, the day on which the 1st of January falls can be calculated using the following formula (Gaus's formula): day = R(1 + 5R(Year-1.4) + 4R(Year-1, 100) + 6R(Year-1, 400), 7) Where R(n, m) is the remainder after dividing n by m e.g. R(10,3) is 1. The formula produces a number in the range 0..6, where Sunday is'=0', Monday is '1', and so on

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Automating Access Databases With Macros

Authors: Fish Davis

1st Edition

1797816349, 978-1797816340

More Books

Students also viewed these Databases questions