1class PrimeNumbers
2{
3 public static void main (String[] args)
4 {
5 int i =0;
6 int num =0;
7 //Empty String
8 String primeNumbers = "";
9
10 for (i = 1; i <= 100; i++)
11 {
12 int counter=0;
13 for(num =i; num>=1; num--)
14 {
15 if(i%num==0)
16 {
17 counter = counter + 1;
18 }
19 }
20 if (counter ==2)
21 {
22 //Appended the Prime number to the String
23 primeNumbers = primeNumbers + i + " ";
24 }
25 }
26 System.out.println("Prime numbers from 1 to 100 are :");
27 System.out.println(primeNumbers);
28 }
29}