• 0

Help with an assignment in C


Question

I need some help with this assignment problem. It's been a while since I last coded in C and i'm quite rusty with it. The problem is as follows:

"Prime numbers may be generated by an algorithm known as the Sieve of Erastosthenes. Write and test a C program that implements this algorithm. Have the program find all the prime numbers up to 150."

Any help? :wacko:

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0

From my classical algebra book:

A tedious process known as the seive of Eratosthenes will yeild all the primes less than any given number N.? It consists of writing down all the numbers from 2 to N-1.? Leave 2 alone and cross out every second number.? The next remaining, namely 3, will be prime; keep it and cross out every third number starting from 3.? The next remaining number, namely 5, will be prime; keep it and cross out every fifth number after 5.? If we procees in this way we will eventually cross out all the composite numbers and all the primes less than N will remain.
Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.