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...

Hi, Anybody could you Please tell me How to write the
script for Checking whether given number is Prime Number or
not..Thanks in Advance

Answer Posted / sumit

//An Extremely Efficient method.
void chkprime(int n)
{
int i=2,j=1;
for(;i<=n/i;j++,i++)
{
if (n%i == 0)
{
break;
}
}

if ( n%i != 0 )
printf("%d is prime. Comparisons: %d\n",n,j);
}

Is This Answer Correct ?    2 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

how to operate webobjects in a webpage using getobject function and then using generic methods?

3039


How to use QTP Object in .vbs(vbscript file) file Ex: Browser().., wait(), exist() and etc...

3395


What aspects of vbscript make it safe so that a web page using vbscript cannot destroy or corrupt information on a user's computer?

1024


What is byref and byval parameters in vbscript?

1034


How will you compare two strings in vbscript?

1015


Mention what is select case statement?

918


how to automatically update the sql server2005 database records when insert in vb6?

1898


What is the purpose of regexp object in vbscript?

975


Program to use input box and send even numbers into sheet1 and odd numbers into sheet2 and prime numbers into sheet3 using vbscript(QTP)?

2998


Which function allows you to instantiate an object given its programmatic identifier or progid?

997


What are events in the vbscript language?

1065


after medical test,when will be the police verification

2118


How to assign a numeric value to a variable?

1073


Why to use option explicit in vb script?

1013


What is loose binding? Why is it not a good practice to use it?

1062