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
Which in-built function is used to format the number in the vbscript language?
What is the main difference between function and sub-procedure?
What is Procedure or Subroutine in VB Script?
How to create a function in vbscript?
What is byref and byval parameters in vbscript?
Mention the environments where vbscript could be run?
How to scroll down a page while recording in qtp. suggest me any method apart from low level recording.
Explain about arrays in vb script?
Explain about tristate constants in vbscript?
Which object provide information about a single runtime error in a vbscript?
How will you convert a string to lower case string using vbscript?
What is the output of a + b in vbscript if a = 5 and b = 10?
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.?
How will you compare two strings in vbscript?
How to capture a runtime error in vbscript?