Print all the prime numbers between 1 and 100 in java by doing coding on mobile

codeYourslf
1 min readMay 1, 2021

--

Hey can do your regular programming using your mobile phone ?

Here I am doing coding using my mobile and sharing it to everyone with proper explanation in my blog codeYourslf.

Here you can learn how to print all the prime numbers present in between 1 and 100.

Approach:-1 "print prime numbers from 1 to 100 in java"

public class ptintBetween {
public static void main(String[] args){
int temp = 0;
for(int i = 2; i <= 100; i++)
{
for(int j = 2; j < i; j++)
{
if(i % j == 0)
{
temp = temp + 1;
}
}

if(temp == 0){
System.out.print(i + ", ");
}
else{
temp = 0;
}
}
}
}

Hey please visit my blog codeYourslf to get all types of programs related to java, python, javascript etc with many approaches to solve them.

Please Click Here :-

--

--

codeYourslf
0 Followers

codeYourslf 👨‍💻 - a programming blog, where you can get different coding programs with so many approaches. please visit :- https://codeyourslf.blogspot.com/