Top suggestions for qs. print if a number n is prime or not (input n from the user). [in this problem you will learn how to check if a number is prime or not] import java.util.*; public class solutions { public static void main(string args[]) { scanner sc = new scanner(system.in); int n = sc.nextint(); boolean isprime = true; for(int i=2; i<=n/2; i++) { if(n % i == 0) { isprime = false; break; } } if(isprime) { if(n == 1) { system.out.println("this is neither prime not composite"); } else { system.out.println("this is a prime number"); } } else { system.out.println("this is not a prime number"); } } } |
- Length
- Date
- Resolution
- Source
- Price
- Clear filters
- SafeSearch:
- Moderate
- Java Method
Creation - Methods in Java
- Interface Default
Method Java - Java
Set Methods - What Is
Method in Java - Java
Constructor Method - Java
Equals Method - Methode
in Java - Method
Reference Java - Java
Super Method - Java Methods
Invoke - W3Schools Java
Function - Program a Bank Using Classes
in Java - Aapna Class
Java Package - MIT Processing in
Eclipse Arbeiten Java - Boolean
in Java - Functions
in Java - Java
Set Bounds Method - Java Text File in
Array Einlesen - Apna College
Java Course - Array and
Methods Java Example - Java
Full-Course Apna College - Int
Method - Return
Object Programming - Get Bedrock in
Survival Java Edition - What Is Functions
in Java in Telugu - Apna College
Java YouTube - Apna College
Java Playlist - Generics
in Java - Java
Placement Course - Java
Tutorial Apna College - Apna College
Java Language - Apna CLG
Java - What Is Java
Bigginer in Kannada - Apna College Java
Class Library - How to
Write hashCode Method in Java - Java
Apna College - What Is
Java Function - Java in
Element Or - Java
From Apna College - How to
Make a Function in a Class Java - Java
Full Course by Shraddha - Java Math Methods
Double Sin Anwendung - Java
All Concepts by Shraddha
Top videos
See more
More like this
