prime numbers

i need prime numberrs program, a program that takes an input from the user and print prime numbers to the user limit.

Comments

  • : i need prime numberrs program, a program that takes an input from the user and print prime numbers to the user limit.
    :

    homework? why don't you write it yourself.
  • : : i need prime numberrs program, a program that takes an input from the user and print prime numbers to the user limit.
    : :
    :
    : homework? why don't you write it yourself.
    :
    Did you know that this was a huge problem some years ago.
    All mathpeople in the world was working on it. Then some
    indian created a computer program in a minute and got
    feamos. I also did a program like that before I knew it
    was hard to do but I didn't get feamos...

    [b]Niklas Ulvinge[/b] [white]aka [b]IDK[/b][/white]

  • : i need prime numberrs program, a program that takes an input from the user and print prime numbers to the user limit.
    :
    One algorithm (the Sieve of Erasmus (sic) I think) goes like this:
    [code]
    Create a list (CL) of all the numbers from 2 to userLimit (UL).

    while numbers left in candidate list (CL)
    Pop a candidate number (CN) off the list
    If CN < sqrt(UL)
    add CN to Primes list (PL)
    iterate through CL
    Remove and discard all numbers evenly divisible by CN
    else
    add all remaining elements of CL to PL

    PL will contain all priomes up to user limit
    [/code]
  • I think it's fair to provide what you tried by now, and someone will correct it if not working. Otherwise you won't understand.

  • Check here is also a similar problem. Good luck

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories