0

I wanna know what numbers are prime before num10 and entered by user with java language

My attempt public class Randam { static int limit; static boolean flag; public static void main(String[] args) { Scanner r = new Scanner(System.in); System.out.println("enter your limit"); int rez=r.nextInt(); for(int i=2;i<limit;i++) { if(limit%2==0) System.out.println("not primre"); } for(int i=0;i<=limit;i++) flag=flag(i); System.out.print(i);

24th Apr 2022, 9:47 PM
Fatma hgazy
Fatma hgazy - avatar
2 odpowiedzi
+ 2
// Hope this code helps you public static boolean isPrime(int num) { for (int i=2; i<num; i++) if (num %i == 0) return false; return true; } public static void main(String[] args) { for(int i=2; i<=10; i++) if (isPrime(i)) System.out.print(i + " "); } https://code.sololearn.com/cl4R5NT4Vjkl
25th Apr 2022, 12:13 AM
SoloProg
SoloProg - avatar
+ 2
loop through numbers then check if they are prime
24th Apr 2022, 10:34 PM
Pls Dont Block Me