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

Why is error handling required?

733


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

819


How will you format a number in percetage format in vbscript?

749


How will you get a combined string from array of string in vbscript?

697


where can i learn VB scripint ?

1788






What is event handling in vbscript?

755


Explain the scope of the variables using dim, public, and private keywords respectively.

899


how to acces the remote mechine using vb cript(QTP)

1745


What is the difference between vb debugger and the script debugger?

762


Mention what if you do not specify anything when you call a procedure?

724


How to Import data from a file (file is on the desktop) to the data table

1760


What is the event handling in vbscript?

720


How do i automate a website www.flyashx.com without having any test cases witin a week time.

1621


what is inner join? what is outer join? what is a constraint? tell me about rdbms? tell me about acid properties?

1597


Explain about the functionality of vb script?

734