Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Sam and Michelle are fond of the Delicious restaurant. Sam will have his dinner in that restaurant on every 'i'th day. Michelle will have her

Sam and Michelle are fond of the "Delicious" restaurant. Sam will have his dinner in that restaurant on every 'i'th day. Michelle will have her dinner on every 'j'th day. Find the day on which Sam andMichelle will have their dinner together in that restaurant. When a day is less than or equal to zero, then display "<'i'th> to <'j'th> is not a valid interval".

Hint: Find out the LCM for given inputs.

Sample Input 1:

Enter the day interval of Sam

4

Enter the day interval of Michelle

6

Sample Output 1:

Sam and Michelle will have their dinner on day 12

Sample Input 2:

Enter the day interval of Sam

6

Enter the day interval of Michelle

8

Sample Output 2:

Sam and Michelle will have their dinner on day 24

Sample Input 3:

Enter the day interval of Sam:

-4

Enter the day interval of Michelle:

6

Sample Output 3:

-4 to 6 is not a valid interval

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

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions

Question

This code is working but I am failing a hidden test. \f

Answered: 1 week ago