Lowest price ever! Learn Generative AI for 48% less!
Get my discount+ 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.
+ 2
Just change this line
for (int i=0;i<35;i++)
+ 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
0
Mr.AnonmyousProgrammer
How many primes are in and out of the range 25 ~ 50?