Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please write in python Your submission should include . For all questions: program codes as .py file. For question 1: text file with prime numbers.

image text in transcribed

please write in python

Your submission should include . For all questions: program codes as .py file. For question 1: text file with prime numbers. For question 3: flow chart in an image format. Submissions in Jupyter Notebook format are also welcome. 1. Prime numbers. When determining prime numbers, one can think of clever ways to reduce the amount of calculations, but we ask you here to use the definition at face value. To check whether a number N is prime divide by all numbers less than N (excluding 1) and check whether N is divisible by one of them. Note that you can stop testing once you have found one divisor, and you can limit this search in the inner loop to numbers up to (N)! (a) Calculate all prime numbers up to 100,000 and write them into the file prime.txt. (b) The last digit of a prime number greater than 2 is 1, 3, 7, or 9, since else they would be divisable by 2 or 5. One could assume that the distribution of these final digits among prime numbers is random. To test this, and in parallel to calculating the prime numbers, find out if there is an equal chance of 25% for a prime number ending on the digit 1 to be followed by a prime number ending in either 1, 3, 7, or 9. To do this, write a function that returns the last digit of an integer number, and determine (within numbers up to 100,000) how many prime numbers there are ending with the digit 1, and how many of these are followed by prime numbers ending in 1, 3, 7, or 9, as percent of the total. Are these all at 25%? Give the results with reasonably formatted output and precision

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

More Books

Students also viewed these Databases questions