Reference no: EM132210109
Write a program that does the following in order:
Asks the user to enter his/her last name.
Asks the user to enter his/her first name.
Prints out the user's first and last names in that order.
Write a program that computes and prints the 1000th prime number.
Initialize some state variables Generate all (odd) integers > 1 as candidates to be prime For each candidate integer, test whether it is prime 1.
One easy way to do this is to test whether any other integer > 1 evenly divides the candidate with 0 remainder. To do this, you can use modular arithmetic, for example, the expression a%b returns the remainder after dividing the integer a by the integer
b. You might think about which integers you need to check as divisors certainly you don't need to go beyond the candidate you are checking, but how much sooner can you stop checking?
If the candidate is prime, print out some information so you know where you are in the computation, and update the state variables Stop when you reach some appropriate end condition.
In formulating this condition, don't forget that your program did not generate the first prime (2). Use these ideas to guide the creation of your code. If you want to check that your code is correctly finding primes, you can find a list of primes.
Write a program that computes the sum of the logarithms of all the primes from 2 to some number n, and print out the sum of the logs of the primes, the number n, and the ratio of these two quantities. Test this for different values of n.
You should be able to make only some small changes to your solution to Problem 2 to solve this problem as well. While you should see the ratio of the sum of the logs of the primes to the value n slowly get closer to l, it does not approach this limit monotonically.