Related questions
Concept explainers
QUADRATIC PRIMES
This question is adopted from Project Euler Question 27. (https://projecteuler.net/problem=27)
The quadratic formula n^2 + n + 41 will produce 40 primes for consecutive integer values 0 <= n <= 39. However, when n = 40, this formula will not generate a prime number.
Another interesting quadratic formula n^2 – 79n + 1601 produces 80 prime numbers for consecutive values 0 <= n <= 79.
The Question: find a and b such that when -999 <= a <= 999 and -1000 <= b <= 1000, the quadratic form ?^2 + ? ×ばつ ? + ? produces the maximum number of primes for consecutive values of n, starting with n = 0.
Requirement:
MUST BE WRITTEN IN C++
- Print the 40 primes generated by formula n 2 + n + 41
- Print the 80 primes generated by formula n 2 – 79n + 1601
- Write a function that takes in an integer and returns whether the given number is prime or not.
- Output the value of a, b and how many consecutive values of n (count the starting zero!) can be generated.
- Submit your .cpp
Trending nowThis is a popular solution!
Step by stepSolved in 4 steps with 3 images
- Given that a,b,c,d,e are distinct whole numbers from 1 to 9 inclusive, along with the equalityab=c⋅100+d⋅10+e where c⋅100+d⋅10+e is the largest possible value, find the value ofa+b+c+d+earrow_forwardplease help with the python problem, thank youarrow_forward%matplotlib inline import numpy as np from matplotlib import pyplot as plt import matharrow_forward
- Okk all doarrow_forward7. The roots of the quadratic equation ax2 + bx + c = 0, a 0 are given by the following formula: -b = √b2 - 4ac 2a In this formula, the term b2 - 4ac is called the discriminant. If b2-4ac0, then the equation has a single (repeated) root. If 200arrow_forwardPlease check my answersarrow_forward
- The daily high temperature (°F) in New York City and Denver, Colorado during the month of January 2004 is given in the vectors below (data from the U.S. National Oceanic and Atmospheric Administration). NYC = [33 33 18 29 40 55 19 22 32 37 58 54 51 52 45 41 45 39 36 45 33 18 19 19 28 34 44 21 23 30 39] DEN = [39 48 61 39 14 37 43 38 46 39 55 46 46 39 54 45 52 52 62 45 62 40 25 57 60 57 20 32 50 48 28] Where, the elements in the vectors are in the order of the days in the month. Write a program in a script file that determines and displays the following information: (a) The average temperature for the month in each city (rounded to the nearest degree). (b) The number of days that the temperature was above the average in each city. (c) The number of days that the temperature in Denver was higher than the temperature in New York.arrow_forwardSuppose that you want to calculate 1434661 · 3785648743 − 100020304 · 54300201. You are told thatthe answer is a positive integer less than 90. Compute the answer mod 10 and mod 9, then combineto get the answer. Show all the necessary work to obtain your answers. Note: This technique hasoften been employed to do calculations with large integers because most of the computations use smallintegers, with only the Chinese Remainder Theorem step requiring large integers. For example, if theanswer is known to be less than 1036, the calculations can be done mod p for each prime less than100. Since the product of the primes less than 100 is approximately 2.3 ×ばつ 1036, the Chinese RemainderTheorem gives the answer exactlyarrow_forward
- Text book imageDatabase System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationText book imageStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONText book imageDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- Text book imageC How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONText book imageDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningText book imageProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education