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

create a form to accept username and password validate the username and password with using message box, display the corresponding user message

2159


What is the use of the formatdatetime function in the vbscript language?

549


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

2030


Can anyone send me a vb script function for verifying the functionality of active links on a web page

1597


How to delete a cookie using vbscript?

551






What are the 2 ways to pass a value to the function?

511


What is the difference between for loop and while loop?

550


How will you reverse a string in vbscript?

620


how to increase the values in text box in a given text box increament by two values by clicking on button

1641


Capture the Unique label changes on google home page for I am feeling lucky button and save those label changes to Notepad Note: Using QTP

1871


can anyone send me a vb scripts code for clicking on a link and coming back on home page again does the same for many links on a web page.

1835


What is the difference between VBScript and JavaScript?

2062


How will you get the natural logarithm of the given number in vbscript?

601


What is the use of the recordset object and which statement is used to create such an object?

527


How can you destroy an object in vbscript?

639