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

Which in-built function is used to format the number in the vbscript language?

1010


What is the main difference between function and sub-procedure?

1045


What is Procedure or Subroutine in VB Script?

1140


How to create a function in vbscript?

1222


What is byref and byval parameters in vbscript?

1069


Mention the environments where vbscript could be run?

1213


How to scroll down a page while recording in qtp. suggest me any method apart from low level recording.

3019


Explain about arrays in vb script?

1052


Explain about tristate constants in vbscript?

1074


Which object provide information about a single runtime error in a vbscript?

1062


How will you convert a string to lower case string using vbscript?

1014


What is the output of a + b in vbscript if a = 5 and b = 10?

3105


Write a function for Instr(). We need to write a function that works as same as Instr(). Code or Even pseudo code is good enough for me.?

2483


How will you compare two strings in vbscript?

1061


How to capture a runtime error in vbscript?

1150