Write a code of prime numbers 1 to 100 and write sql query.
Code for prime numbers 1 to 100 and SQL query.
Use a loop to iterate through numbers 1 to 100.
For each number, check if it is divisible by any number from 2 to itself-1.
If not divisible, it is a prime ...read more
SQL query: SELECT * FROM table_name WHERE number_column >= 1 AND number_column <= 100 AND is_prime = true;
code:
import java.util.*;
public class Main {
public static void main(String args[]){
int num;
Scanner sc = new Scanner(System.in);
num = sc.nextInt();
int c = 0;
for(int i=0; i<=num; i++){
if(i%num == 0)
c++;
}
if(c == 2){
System.out.println("Prime No.");
}else{
System.out.println("Not a Prime No.");
}
}
}
Top Accenture Java Developer interview questions & answers
Popular interview questions of Java Developer
Top HR questions asked in Accenture Java Developer
Reviews
Interviews
Salaries
Users/Month