prime numbers - Programmers Heaven

Howdy, Stranger!

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

Categories

prime numbers

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

Comments

  • stoberstober Posts: 9,765Member ✭✭✭
    : 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.
  • IDKIDK Posts: 1,784Member
    : : 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]

  • tom_swtom_sw Posts: 828Member
    : 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]
  • globalprogglobalprog Posts: 67Member
  • sunlotussunlotus Posts: 55Member

    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.

  • sunlotussunlotus Posts: 55Member

    Check here is also a similar problem. Good luck

Sign In or Register to comment.