

|
 |
| Programming > Fortran > Re: Simple Prog... |
|
| << Topic |
< Post |
Post 21 of 34 Topic 8551 of 8908
|
Post > |
Topic >> |
Re: Simple Program, Lots of Issues (F90)
by Ron Ford <ron@[EMAIL PROTECTED]
>
Jul 25, 2008 at 04:57 PM
| On Fri, 25 Jul 2008 06:57:35 -0700 (PDT), e p chandler posted:
> On Jul 25, 3:36 am, Ron Ford <r...@[EMAIL PROTECTED]
> wrote:
>> On Thu, 24 Jul 2008 10:55:18 -0700 (PDT), ALevenson posted:
>>
>>> I just picked up Fortran yesterday at the suggestion of my mentor,
>>> which for me means I glance through a tutorial and try to get a
>>> program running that finds primes.
>
> [snip]
>>
>>> program primes
>>
>>> integer :: i, j, k, l, m, n, x
>>> real :: t
>>> logical :: notprime, even
>>
>>> ! Program finds primes up to
>>> ! upper limit 'x' as defined by user
>
> [snip]
>
>>> l = SQRT( i )
>>> do m = 3, l, 2
>>> n = m / 2
>>> t = m / 2
>>> if ( n == t ) then
>>> notprime = 1
>
>> Is this to be the sieve of eratosthenos?
>
> see ftp://ftp.swcp.com/pub/walt/F/Examples/sieve.f95
>
> The program comments are 1) in verse and 2) excerpted from a work of
> science fiction. :-).
>
> - e
! Strike the Twos and strike the Threes
! The Sieve of Eratosthenes!
! When the multiplies sublime
! The numbers that are left, are prime.
If you include a poem in an algorithm, I think it's artistry of the
highest
form. I always think that compiler switches are difficult when I start
into a new syntax. This might be informative for OP:
C:\Do***ents and Settings\dan\Desktop\gfortran\source>gfortran -o sieve
sieve1.f95
C:\Do***ents and Settings\dan\Desktop\gfortran\source>sieve
There are 25 prime numbers less than 100
2 3 5 7 11
13 17 19 23 29
31 37 41 43 47
53 59 61 67 71
73 79 83 89 97
The source is also well-polished at that link. The sieve of eratosthenos
is an outstanding pedagogical tool for either number theory or algorithms,
as one can easily do it on paper.
--
When a new source of taxation is found it never means, in practice, that
the old source is abandoned. It merely means that the politicians have two
ways of milking the taxpayer where they had one before. 8
H. L. Mencken


|
34 Posts in Topic:
|
ALevenson <Andrew.Leve |
2008-07-24 10:55:18 |
|
ALevenson <Andrew.Leve |
2008-07-24 10:59:09 |
|
Craig Powers <craig.po |
2008-07-24 14:11:46 |
|
Paul van Delst <Paul.v |
2008-07-24 14:15:22 |
|
Dick Hendrickson <dick |
2008-07-24 18:06:28 |
|
Craig Powers <craig.po |
2008-07-24 14:09:35 |
|
ALevenson <Andrew.Leve |
2008-07-24 11:12:13 |
|
Craig Powers <craig.po |
2008-07-24 14:15:20 |
|
ALevenson <Andrew.Leve |
2008-07-24 11:19:35 |
|
Alois Steindl <Alois.S |
2008-07-24 20:28:47 |
|
Sebastian Hanigk <hani |
2008-07-24 20:45:13 |
|
ALevenson <Andrew.Leve |
2008-07-24 11:40:38 |
|
Gib Bogle <bogle@[EMAI |
2008-07-25 09:47:44 |
|
dpb <none@[EMAIL PROTE |
2008-07-24 17:43:53 |
|
"Kevin G. Rhoads&quo |
2008-07-25 20:29:05 |
|
dpb <none@[EMAIL PROTE |
2008-07-25 17:21:03 |
|
Richard L Walker <rlwa |
2008-07-25 19:06:03 |
|
dpb <none@[EMAIL PROTE |
2008-07-25 19:15:40 |
|
Ron Ford <ron@[EMAIL P |
2008-07-25 01:36:42 |
|
e p chandler <epc8@[EM |
2008-07-25 06:57:35 |
|
Ron Ford <ron@[EMAIL P |
2008-07-25 16:57:39 |
|
"Dr Ivan D. Reid&quo |
2008-07-25 23:12:58 |
|
e p chandler <epc8@[EM |
2008-07-25 17:14:15 |
|
nospam@[EMAIL PROTECTED]
|
2008-07-25 17:30:39 |
|
Ron Ford <ron@[EMAIL P |
2008-07-25 22:49:22 |
|
e p chandler <epc8@[EM |
2008-07-25 18:02:47 |
|
AnotherSquid <mai@[EMA |
2008-07-29 07:26:26 |
|
"Dr Ivan D. Reid&quo |
2008-07-29 19:07:40 |
|
Reinhold Bader <Bader@ |
2008-07-29 21:19:21 |
|
Craig Powers <craig.po |
2008-07-29 15:29:20 |
|
"Dr Ivan D. Reid&quo |
2008-07-29 22:51:25 |
|
Tobias Burnus <burnus@ |
2008-07-29 11:39:10 |
|
kargl@[EMAIL PROTECTED]
|
2008-07-29 19:29:07 |
|
AnotherSquid <mai@[EMA |
2008-07-30 06:49:43 |
|
Post A Reply:

|
|
|
|