Prime number finder - Programmers Heaven

Howdy, Stranger!

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

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Prime number finder

depro94depro94 Posts: 1Member
Hello guys, I'm new to programming, I had some Pascal classes last year and I found it pretty interesting, so I've given it a try and began doing some projects at home.

Recently I was thinking of how useful a prime number finder would be. And Im pretty sure there are millions out there, but I tried to build my own.
. After some struggle (and perhaps, as you'll see, some redundancies) I've came up with my own design. You enter the lower and upper values and the program will give you all the primes between both values. Problem is, it stops after "finding" the number 61. No matter what range I use! Could you please help me out?

Comments

  • quikcarlxquikcarlx Hollywood, FlPosts: 26Member
    I don't know about your program and the problems that you are having. I have written a prime number finder that goes from 3 to 1,000,000 putting the results in a file, which you can change if you change my program. But first some rules that I use:
    [code]{----------------------------------------------------------------------------}
    { Prime determination from 4 rules: }
    { 1) all primes greater than 2 are odd }
    { 2) it's necessary to try division by all lower primes, but there's no }
    { efficient way to do this, so MOST odd numbers starting from 3 are used }
    { 3) it's necessary to try odd divisors only up to the square root of the }
    { new trial prime number (beyond that you would be traversing a range of }
    { numbers already ruled out) }
    { 4) prime numbers above 2 end either in 1, 3, 5, 7, or 9, it is un- }
    { necessary to test for numbers ending in 5, since they are divisible }
    { by 5 }
    {----------------------------------------------------------------------------}
    [/code]
    Now I have honed and refined my algorithm for accuracy and speed and by using Free Pascal 2.6.0 compiler. So as an attachment, you can download the program, and give credit where credit is due.

Sign In or Register to comment.