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

Can u describe what kind of testing are for OTC derivates by banks.

1893


Mention what is vbscript procedures?

763


Explain How do you create a recordset object in vbscript?

803


Why is it recommended to close the database connection every time after the work is completed?

717


How will you check that a variable is an array in vbscript?

757


What are the properties of regexp object?

804


What are the different types of loops available in the vbscript language?

740


How to declare an array in vbscript?

897


How to open a file. What is the perpose of true and false mode there?

844


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

1764


What is the difference between do until loop and do while loop?

802


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.

1655


What are the data types supported by vbscript?

808


How to make sure that items in a wintree are sorted al?

2578


I need to get some data from data base and store this (retrieved) data in a excel sheet using VB script in QTP9.0 I have created connection for data base I have created as excels sheet by using Set XL=CreateObject("Excel.Application") XLworksheet.cells(1,1).value= rs.fields.item("<>") I have taken a for loop and changed the cells values (1 as i and another 1 as j) But still I am not able to get Plz kindly tell me know this . It is very urgent

1993