Write a code of prime numbers 1 to 100 and write sql query.

AnswerBot
1y

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

Sai Patnaik
1y

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.");

}

}

}

Help your peers!
Add answer anonymously...
Accenture Java Developer Interview Questions
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+

Reviews

4 L+

Interviews

4 Cr+

Salaries

1 Cr+

Users/Month

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter