Sololearn: Learn to Code
New course! Every coder should learn Generative AI!
Try a free lesson
+ 4
public class Main { public static void main(String[] args) { int a[]=new int[35]; int i,count=0; a[0]=1; for(i=1;i<a.length;i++) { a[i]=a[i-1]+2; } System.out.print("Prime numbers between 25 and 50 are: "); for(int j : a) { int c=0; for(i=1;i<=j;i++) { if(j%i==0) c++; } if(c==2) { if(j>25&&j<50) System.out.print(j+" "); else count++; } } System.out.print("\nPrime numbers not in range: "+count); } } Mr.AnonmyousProgrammer Try this. Previous code has some logical errors.
9th Apr 2021, 4:19 PM
ᗩηιηɗуα ᗩɗнιкαяι
+ 2
Just change this line for (int i=0;i<35;i++)
22nd Mar 2021, 1:49 PM
Atul [Inactive]
+ 2
On the line 14 : After if statement there are no curly braces. Maybe I was incorrect. Bcuz I am not that expert in java
20th Apr 2021, 1:41 AM
purveshKolhe
purveshKolhe - avatar
0
Mr.AnonmyousProgrammer How many primes are in and out of the range 25 ~ 50?
22nd Mar 2021, 2:51 PM
Ipang