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

I have attended Anovatek Software QTP interview. They will give us computer and one web based application with QTP. We have to automate some records (already updated records or new records) using QTP Data driven testing. But we should use for loop? Can any one know how to do data driven testing using For loop?

1781


Mention what is the use of option explicit in vbscript?

790


Explain about constants in vb script?

811


Which constant is used for print and display functions and works as same as pressing enter key?

793


How to open browser in vb script?

863


What is difference between vbscript and vba?

894


What are the environments supported by vbscript language?

736


Explain about tristate constants in vbscript?

853


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

857


What is the scope of a constant declared using public?

772


Explain about filter expression?

807


Which function is used to perform string comparison?

836


What is the use of the instr function?

825


Why is error handling required?

799


why variable name should not exceed 255 characters?

2028