Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Nowadays some proofs are generated by computer. In 1976, the four color theorem was the first major theorem to be verified using a computer

 

Nowadays some proofs are generated by computer. In 1976, the four color theorem was the first major theorem to be verified using a computer program. In this assignment you will write a computer program to disproof a statement by finding a counterexample. The statement is the following: Every odd number from 3 onwards can be written as the sum of a prime number and twice a square. Some odd numbers (that are greater than or equal to 3) can be written as the sum of a prime number and twice a square. For example, 3=3+2(0), 5 = 3+2(1), 7=5+2(1), 9=7+2(1), 11=3+2(2), 13=5+2(2), 15=7+2(2), etc. But not all of the odd numbers can be written like that. You need to write a program that would find the smallest counterexample, that is, the smallest odd number (23) that cannot be written as the sum of a prime number and twice a square. (Hint: The smallest counterexample lies between 1000 and 10000.) One way to solve it is the following: generate a list of squares and check odd numbers to see if the number minus twice a square is a prime. You need to do the following: (1) Write a method that takes a natural number n as a parameter and determines if n is a prime number. (2) Generate a list of the first 100 squares (from 0 to 99) and put them in an array of size 100. (100 is enough because 100-10000 and we know that there is a counterexample between 1000 and 10000.) (3) For every odd number n starting from 3 check whether it can be written as the sum of twice a square and a prime number. To do it, go through the squares in the squares array. For each square, multiply it by 2 and subtract the result from the number n. Use your method from (1) to check whether the difference is a prime number or not. If it is not a prime number then do the same for the next square in the squares array. Otherwise, if the difference is prime, the number n can be written in the desired form so you need to check the next odd number. Continue until you find the smallest counterexample. (4) Output the smallest counterexample which you find.

Step by Step Solution

3.42 Rating (158 Votes )

There are 3 Steps involved in it

Step: 1

1 Project 7 Structure 2 Favorites HN3693927 10 11 12 13 14 o Run HI Four... 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_2

Step: 3

blur-text-image_3

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

Accounting Principles Part 3

Authors: Jerry J. Weygandt, Donald E. Kieso, Paul D. Kimmel, Barbara Trenholm, Valerie Kinnear, Joan E. Barlow

6th Canadian edition Volume 1

1118306805, 978-1118306802

More Books

Students also viewed these Accounting questions

Question

Which are the strongest parts?

Answered: 1 week ago

Question

Which character has an opposite script?

Answered: 1 week ago