1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

How to tell Fortran to get rid of composite numbers?

  1. Apr 30, 2013 #1
    Problem Statement: Do the sieve of Eratosthenes from 2 to 100 and find all the primes


    So I'm trying to do the sieve of Eratosthenes in fortran 90 (I'm using Plato IDE)


    My efforts to solve this/ method to use:

    Obviously, I want the program to do a LOOP starting with every whole number from 2 onwards, and then get rid of all multiples of that number before the next LOOP starts with the next number and so on.

    But how do I tell fortran that it should take a number and then strike all multiples of it, essentially getting rid of all composite numbers?


    Relevant equation: THATs the one I am searching for, which is why I need your help.

    thanks for any help,
    Sir Arun
     
    Last edited: Apr 30, 2013
  2. jcsd
  3. Apr 30, 2013 #2

    mfb

    User Avatar
    2016 Award

    Staff: Mentor

    You need some way to hold information ("prime"/"not prime") about 100 numbers in such a way that you can easily access any random element of them. Which data type would you choose?
     
  4. Apr 30, 2013 #3

    Mark44

    Staff: Mentor

    You seem to think that there is some magic formula or equation that will be of use here. That's not true.

    What you really need is an algorithm, a sequence of steps to be performed.

    For a given number between 2 and 100, how would you manually determine that it is either composite or prime?
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?
Draft saved Draft deleted



Similar Discussions: How to tell Fortran to get rid of composite numbers?
Loading...