Find and print all of the prime numbers between 3 and k

Assignment Help Computer Engineering
Reference no: EM132211280

Write a program that reads in an integer that is greater than 2 (let's call it k) and finds and prints all of the prime numbers between 3 and k.

A prime number is a number such that 1 and itself are the only numbers that evenly divide it (for example, 3, 5, 7, 11, 13, 17, ...). One way to solve this problem is to use a doubly nested loop.

The outer loop can iterate from 3 to k while the inner loop checks to see if the counter value for the outer loop is prime.

One way to see if number n is prime is to loop from 2 to n-1 and if any of these numbers evenly divides n, then n cannot be prime. If none of the values from 2 to n-1 evenly divides In, then n must be prime.

Reference no: EM132211280

Questions Cloud

What you have learned in the given class : Reflect on what you have learned in this class. Describe the significant ways in which you can now utilize critical thinking in your personal and professional.
What was the percentage change of multi-factor productivity : What was the percentage change of multi-factor productivity from June to July?
How gender roles relate to your personal life : Throughout human history the first question parents have asked at the birth of a child has been whether the child is a boy or a girl.
Write a program that prompts the user for the two legs : Write a program that prompts the user for the two legs of a right triangle and makes use of the pow and sqrt functions.
Find and print all of the prime numbers between 3 and k : Write a program that reads in an integer that is greater than 2 (let's call it k) and finds and prints all of the prime numbers between 3 and k.
Use the holistic marketing framework : Discuss in detail how an organisation such as Coca-Cola could use the holistic marketing framework to grow their market share and increase customer satisfaction
How christian ethics would approach a values-based issue : Write an essay (600 - 1000 words) that compares how Christian ethics and an ethical theory of your choice would approach a values-based issue.
Preliminary cost bene?t analysis for client-server system : Martin is working to develop a preliminary cost bene?t analysis for a new client-server system.
Discuss extra-dimensional communication within the event : Discuss extra-dimensional communication within this event (for example, presence/absence/how it could be attained or improved for future communication).

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