I am trying to create a perl program that will find all of the prime numbers between 1 and 10. does anyone know of an equation that can be used with perl in order to get that. or am i looking at this all wrong.
Thanks
Man Discovers Nicest Gas Station Toilet Ever in Real World News 


Recommend me Anime in General Discussion 


PGP Error with Linux Mint in Linux / Unix Discussion & Support 


Denver man finds a box full of rocks in the PS4 bundle he bought at Walmart in Real World News 


How to pronounce "Israel"? in General Discussion 

Posted 28 January 2008  16:49
Posted 28 January 2008  20:07
Edited by rpgfan, 28 January 2008  20:14.
Posted 29 January 2008  12:58
Posted 29 January 2008  13:43
Correct. More info on that technique: http://mathforum.org....prime.num.htmlThere's no formula to generate all the primes. Either look at each number in turn and check if it's divisible by any of the (prime) numbers smaller than (the square root of) it, or start with an array of all the numbers then strike out all the multiples of 2, then all the multiples of 3, then 5 etc
Posted 29 January 2008  19:09
#! use strict; my @list = 1..100; foreach $a (@list){ my@total=(); foreach $b(@list){ if ((int($a/$b)==($a/$b))){ push @total, $b; } } print "$a is prime\n" if($#total == 1); }