public class PrimeNumber1To100 {
public static void main(String[] args) {
System.out.println("Prime numbers from 1 to 100 are :");
for(int i=1;i<=100;i++) {
int counter=0;
for(int num = i;num>=1;num--) {
if(i%num == 0) {
counter++;
}
}
if(counter == 2) {
System.out.print(i+" ");
}
}
}
}
Output:-
Prime numbers from 1 to 100 are :
2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97
Thursday, August 5, 2021
How to find prime numbers from 1 to 100
Subscribe to:
Post Comments (Atom)
How to find middle node of LinkedList without using extra memory in java
To find the middle node of a LinkedList without using extra memory in Java, you can use the "tortoise and hare" algorithm. This al...
-
import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.LinkedHashMap; import java....
-
how to install cvs on debian Install the cvs follow these steps: 1.install cvs and cvsd #apt-get install cvs cvsd When configuring cvsd I wa...
-
public class SumPair { public static void main(String[] args) { int arr[] = {5,7,8,3,1,4,6,9,2}; int n = 12; findPair(arr,n); ...
No comments:
Post a Comment