Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please read all the parts very carefully and then write the code. Really looking for help. Conjecture: Given two positive integers a and b, if

Please read all the parts very carefully and then write the code. Really looking for help.

Conjecture: Given two positive integers a and b, if (ab + 1) evenly divides (a2 + b2), let r = (a2 + b2) / (ab + 1). Then r is a perfect square. Your program should start by prompting the interactive user for a positive integer that is used to determine the range of a and b numbers you will search for evidence about that conjecture. Let us call that number X. Limit X to a number between 1 and 100000, inclusive. If the user enters a non-integer, output a descriptive error message, and reprompt. If the user enters an integer outside the proper range, output a descriptive error message, and reprompt. NOTE: you are required to make a and b POSITIVE integers (zero is not allowed). When you have obtained a legal X from the user, run through all the possible combinations of a and b where a and b can take on the numbers from 1 to X, inclusive. This will require testing X2 different (a,b) pairs. For each pair, test first to see if (a2 + b2) / (ab + 1) is an integer. If it is not an integer, skip to the next (a,b) pair. If (a2 + b2) / (ab + 1) IS an integer, check to see if that integer is a perfect square. If you find that for this (a,b) pair, (a2 + b2) / (ab + 1) is a perfect square integer, print a line to the screen that informs the user of the values of a, b, r, and the square root of r. Make sure that the user will readily understand your output, even if your results fill up more than a screen of your IDE. While you are doing these tests, keep track of how many times you discover that (a2 + b2) / (ab + 1) is an integer, and how many times that integer is a perfect square. After your program goes through all of the possible pairs, print to the screen how many (a,b) pairs made for an integer, and how many of those integers were perfect squares. Again, label appropriately. (Big hint: the conjecture says that these two numbers should be identical.)

Develop and test your code to accomplish all of the above before going on to the next part of the specification. Now that your program is running smoothly, identifying and displaying all the (a,b) pairs that give an acceptable r, refactor your code to do the following: After you accomplish the tasks above, repeat the action above, but change things up in the second part so that it does NOT print out anything to the screen while it tests the (a,b) pairs. Instead, it merely keeps track of how many times you discover that (a2 + b2) / (ab + 1) is an integer, and how many times that integer is a perfect square. Your program must determine how much clock time passes in order to do the first part of the program (with printing to the screen), and how much clock time passes for the second part of the program (not printing to the screen each time you find a special (a,b) pair). The idea here is to see how much slower a program runs when it is required to IO to the screen. Time the second part from when it starts calculating to just before the second part prints anything to the screen.After you have tested all the (a,b) pairs for the second time, report to the interactive user via the screen the following: The largest number allowed for a and b (this is called X above), and the number of pairs tested (X2) How much time was required for the first part of the program (that prints to the screen more often), and how much time was required for the second part (before any printing to the screen occurred). How many of those X2 (a,b) pairs made (a2 + b2) / (ab + 1) an integer. How many of those integers were perfect squares. Again, make sure that the interactive user will know what those numbers mean. That is, dont just print the numbers to the screen with no explanation of what the numbers mean:

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

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2022 Grenoble France September 19 23 2022 Proceedings Part 4 Lnai 13716

Authors: Massih-Reza Amini ,Stephane Canu ,Asja Fischer ,Tias Guns ,Petra Kralj Novak ,Grigorios Tsoumakas

1st Edition

3031264118, 978-3031264115

More Books

Students also viewed these Databases questions