Compute the sum of the logarithms of all the primes

Assignment Help Computer Engineering
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.

Reference no: EM132210109

Questions Cloud

Write a program that generates a password based on number : Write a program that generates a password based on the number of digits provided by the user.
HRM technology to create strategic focus : Review an example through research on how a business has used HRM technology to create a strategic focus.
A program to generate 100 random integers between 0 and 9 : Write a program to generate 100 random integers between 0 and 9, and display the count for each number, like how many 2s, and how many 5s, etc.
Write abstract of the given topic : Description: In this assignment, you will first write your conclusion; then, you will write your abstract. The following components are requirements.
Compute the sum of the logarithms of all the primes : 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.
Do they have trust flag on their homepage : Do they have a trust flag on their homepage? What is it and why is it important for them – hint do you think their customer might be a bit older?
Skills required to perform work effectively and efficiently : Prepare an organizational structure for a department store such as Target and identify the skills required to perform the work effectively and efficiently.
What are some questions that occur to you : Read the introduction to Book: A Futurist's Manifesto. Then please look over the table of contents and choose two other essays from the book to read.
Write a program that gets a string from the user : Write a program that gets a string from the user and assign it to a variable named prefixes.

Reviews

Write a Review

Computer Engineering Questions & Answers

  Can you devise a meet-in-the- middle attack for a triple des

If the key with parity bit (64 bits) is 0123 ABCD 2562 1456, find the first round key. Can you devise a meet-in-the- middle attack for a triple DES?

  Describes the findings of other researchers

Write a review of the literature that describes the findings of other researchers related to a specific topic in the Project Management field.

  How many block frames are there in the cache

How many block frames are there in the cache? Explain the bit fields needed for addressing each word in the two-level memory system.

  How is the synchronous timing diagram affected

How is the synchronous timing diagram affected as distance between the processor and the I/O device increases.

  Describe the costs and benefits alternative solutions

Describe the costs and benefits of each situation." So, as you would prefer for this meeting, perhaps you might anticipate questions that would be asked regarding this section.

  Design a data management software on c

Using Structures, Unions, Files and Dynamic Memory allocation and all semester's topics design a Data Management Software on C.

  Use apa format and have a list of references

As you are aware a software product license grants individuals the legal right to run or access a software program. A license agreement governs the use of the licensed software program. One of the ongoing sagas in Information Technology is the que..

  Define and explain the regular laminate

Define and explain the Regular laminate, Balanced laminate, and Specially orthotropic laminate.

  Returns the total charges for an oil change and lube job

Returns the total charges for an oil change and/or lube job, if any. FlushCharges: returns the total charges for a radiator flush and/or transmission flush, if any.

  Discuss about the networking issues

The client you have been working with in your Weeks Two, Three, and Four individual assignments has received calls from its multiple locations complaining.

  Write a program that asks user for the name of an employee

Write a program that asks the user for the name of an employee, finds the record with that name, and displays the record.

  Is this a good padding scheme and why

When using a block cipher to encrypt a message, padding is usually needed.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd