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

  Mathematics in computing

Binary search tree, and postorder and preorder traversal Determine the shortest path in Graph

  Ict governance

ICT is defined as the term of Information and communication technologies, it is diverse set of technical tools and resources used by the government agencies to communicate and produce, circulate, store, and manage all information.

  Implementation of memory management

Assignment covers the following eight topics and explore the implementation of memory management, processes and threads.

  Realize business and organizational data storage

Realize business and organizational data storage and fast access times are much more important than they have ever been. Compare and contrast magnetic tapes, magnetic disks, optical discs

  What is the protocol overhead

What are the advantages of using a compiled language over an interpreted one? Under what circumstances would you select to use an interpreted language?

  Implementation of memory management

Paper describes about memory management. How memory is used in executing programs and its critical support for applications.

  Define open and closed loop control systems

Define open and closed loop cotrol systems.Explain difference between time varying and time invariant control system wth suitable example.

  Prepare a proposal to deploy windows server

Prepare a proposal to deploy Windows Server onto an existing network based on the provided scenario.

  Security policy document project

Analyze security requirements and develop a security policy

  Write a procedure that produces independent stack objects

Write a procedure (make-stack) that produces independent stack objects, using a message-passing style, e.g.

  Define a suitable functional unit

Define a suitable functional unit for a comparative study between two different types of paint.

  Calculate yield to maturity and bond prices

Calculate yield to maturity (YTM) and bond prices

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