Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

write a script to generate n prime no.s?

Answer Posted / venkat

#!c:\perl\bin\perl

$Count = 0;
$pt = 2;
while ( $Count < @ARGV[0] )
{
if (isPrimary($pt))
{
print "$pt\n";
$Count++;
}
$pt++;
}

sub isPrimary
{
$flag = 1;
for ($i=2; $i<=$_[0]/2; $i++)
{
if ($_[0] % $i == 0)
{
$flag = 0;
}
}
return $flag;
}

Is This Answer Correct ?    16 Yes 4 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Define dynamic scoping.

883


Explain chomp, chop, cpan, tk.

929


explain the various functions/directives in perl that allow you to include/import a module. Also, state the differences between them.

864


what is the difference between java and cgi?

1069


You want to connect to sql server through perl. How would you do that?

928


What is the use of "stderr()"?

1017


Write a program to concatenate the $firststring and $secondstring and result of these strings should be separated by a single space.

1048


What package you use to create a windows services?

883


What are some common methods to all handles in perl?

918


Comment on data types and variables in perl.

922


How to concatenate strings with perl?

861


Explain cpan?

972


What are the reasons that cookie server can’t handle multiple connections?

948


When would `local $_' in a function ruin your day?

948


What are the advantages of perl programming?

993