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 / anant

boolean isPrime(int num){
if(num==0 || num==1){
System.out.println("Number should be greater than 1");
System.Exit(0);
}
if(num%2==0 || num%3==0 || num%5==0 || num%7==0)
System.out.println("Number is not prime");
else
System.out.println("Number is prime");
}

Is This Answer Correct ?    2 Yes 14 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How will you get the largest subscript of an array in vbscript?

896


Give me sm ideas to write Vbscripts abt protocol testing abilash700@gmail.com.

1865


How to open browser in vb script?

850


I am working on QTP, got struck in one place.. In my application depending upon configuration WebEdit count is increasing/ decreasing.. how to get these webedits..

2027


if u ve resrevation for train and u get a number supose 1234xxxokie.after sucessul entering all required fields. now u put that number in search and want to chk wether these ar same or not if both ar same then its okie otherwise test fail.what would be the vb script code for it to compare these two values of different page.

1670


How to assign a date value to a variable?

805


how to write a vb script in QTP for yahoo registration form, i want to check the performance also like performance test, stress, load test like that.

5001


Is vbscript language a case-sensitive language and what does it mean?

785


What are the uses of vb script?

832


Which data type/types are supported by vbscript language and what are their specialties?

827


What are the special sub-types in vbscript?

794


Explain the tristate constants in vbscript?

805


What is vbscript procedures?

848


What is the use of the instr function?

817


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

805