m_heimburger has asked for the wisdom of the Perl Monks concerning the following question:
Yeah... you gessed right - I'm trying to make a program that works out prime number up to a certain limit... I know this is really inefficient, weird, etc. but I've only started programming. Thanks for your help in advance, Martinprint "Enter a limit\n"; $limit = <STDIN>; @primes = (2); $number = 2; $something = 1; while ($number < $limit) { $something = 1; foreach $div (@primes) { print "Dividing $number by $div\n"; if ($number % $div == 0) { print "$number ist no Primnumber\n"; $number++; $something = 0; } } if ($something == 1) { print "$zahl is no prime number\n"; push (@primes, $number); $number++; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Newbie Question on pushing Arrays
by arturo (Vicar) on May 04, 2001 at 20:11 UTC | |
by m_heimburger (Initiate) on May 04, 2001 at 20:43 UTC | |
by chipmunk (Parson) on May 04, 2001 at 20:54 UTC | |
by buckaduck (Chaplain) on May 04, 2001 at 21:00 UTC | |
by m_heimburger (Initiate) on May 04, 2001 at 21:05 UTC | |
|
Re: Newbie Question on pushing Arrays
by Anonymous Monk on May 04, 2001 at 20:06 UTC | |
by JojoLinkyBob (Scribe) on May 04, 2001 at 20:30 UTC | |
by no_slogan (Deacon) on May 04, 2001 at 22:24 UTC |