java program to find prime number between 1 and 100
Java
class PrimeNumbers
{
public static void main (String[] args)
{
int i =0;
int num =0;
//Empty String
String primeNumbers = "";
for (i = 1; i <= 100; i++)
{
int counter=0;
for(num =i; num>=1; num--)
{
if(i%num==0)
{
counter = counter + 1;
}
}
if (counter ==2)
{
//Appended the Prime number to the String
primeNumbers = primeNumbers + i + " ";
}
}
System.out.println("Prime numbers from 1 to 100 are :");
System.out.println(primeNumbers);
}
}
Also in Java:
- Title
- show menuitem when menu hovered javafx
- Category
- Java
- Title
- setting up javafx in eclipse
- Category
- Java
- Title
- convert hashset to int array java
- Category
- Java
- Title
- create java windows application
- Category
- Java
- Title
- how to print a 2d array in java
- Category
- Java
- Title
- java - a program to print open ports
- Category
- Java
- Title
- spigot chat color with symbol
- Category
- Java
- Title
- java throws multiple exceptions
- Category
- Java
- Title
- how to input in java
- Category
- Java
- Title
- override java
- Category
- Java
- Title
- java how to print a newline
- Category
- Java
- Title
- 2d array length in java
- Category
- Java
- Title
- java calendar add minutes
- Category
- Java
- Title
- non primitive data types in java
- Category
- Java
- Title
- get day name from date in java
- Category
- Java
- Title
- jtable get get row
- Category
- Java
- Title
- computeifabsent hashmap java
- Category
- Java
- Title
- how to exit a for loop in java
- Category
- Java
- Title
- get preference value android
- Category
- Java
- Title
- simple javascript to detect browser using java utils
- Category
- Java
- Title
- java how to call getReader twice
- Category
- Java
- Title
- import java.util.hashset
- Category
- Java
- Title
- get host from request object java
- Category
- Java
- Title
- how to calculate exponential in java
- Category
- Java
- Title
- how to open a webpage with java
- Category
- Java
- Title
- bukkit register commands
- Category
- Java
- Title
- change the value in a hashtable java
- Category
- Java
- Title
- how to get length of integer in java
- Category
- Java
- Title
- eliminar fila jtable java
- Category
- Java
- Title
- icon label java
- Category
- Java
- Title
- faire un timer en java
- Category
- Java
- Title
- java calculator code
- Category
- Java
- Title
- logger in java
- Category
- Java
- Title
- take string from keyboard java
- Category
- Java
- Title
- string reverse in java
- Category
- Java
- Title
- removeeventlistener
- Category
- Java
- Title
- print hashtable in java
- Category
- Java
- Title
- java integer to binary string
- Category
- Java
- Title
- java convert char to int
- Category
- Java
- Title
- how to use for loop for array in java
- Category
- Java
- Title
- print map java
- Category
- Java
- Title
- java function that returns the index of the largest value in an array
- Category
- Java
- Title
- how to use lambda in java
- Category
- Java
- Title
- how to check if an arraylist contains a value in java recursion
- Category
- Java
- Title
- how to bubblesort a string array in java
- Category
- Java
- Title
- byte java
- Category
- Java
- Title
- stackoverflow java enum with constructor
- Category
- Java
- Title
- mkyong restful web services spring boot examples post
- Category
- Java
- Title
- how to get all the names of the files in a folder in java?
- Category
- Java
- Title
- java create file with content
- Category
- Java
- Title
- java string to character stream
- Category
- Java
- Title
- declare class variable in java
- Category
- Java
- Title
- using get in map in java
- Category
- Java
- Title
- BoxLayout java
- Category
- Java
- Title
- bootstrap alert
- Category
- Java
- Title
- lastindexof java
- Category
- Java
- Title
- double parse jtextfield
- Category
- Java
- Title
- do while loop java
- Category
- Java
- Title
- programa que convierete un archi de c a java
- Category
- Java
- Title
- java last element in array
- Category
- Java
- Title
- tower of hanoi program in java using recursion
- Category
- Java
- Title
- java stack
- Category
- Java
- Title
- primitive and non primitive data types in java
- Category
- Java
- Title
- java read each lines in file
- Category
- Java
- Title
- threadsafe singleton pattern in java
- Category
- Java
- Title
- java script to detect and launch all browsers
- Category
- Java
- Title
- declareing a variable in java
- Category
- Java
- Title
- char array to arraylist java
- Category
- Java
- Title
- Spigot API inventory close
- Category
- Java
- Title
- java string to lower case
- Category
- Java
- Title
- java list contains object with property
- Category
- Java
- Title
- android studio keep device awake
- Category
- Java
- Title
- how to find length of array in java
- Category
- Java
- Title
- Could not resolve project :app
- Category
- Java
- Title
- java variable declaration
- Category
- Java
- Title
- how to write a perfect shuffle method in java
- Category
- Java
- Title
- hashmaps java
- Category
- Java
- Title
- java loop through map
- Category
- Java
- Title
- login and logout react native and firebase
- Category
- Java
- Title
- java generate list of random element
- Category
- Java
- Title
- android java add new record to Firebase Firestore
- Category
- Java
- Title
- what is a variable in java
- Category
- Java
- Title
- how to get the dimensions of a 2d array in java
- Category
- Java
- Title
- make recycler view non scrollable
- Category
- Java
- Title
- minecraft sounds spigot
- Category
- Java
- Title
- 2d array java
- Category
- Java
- Title
- while loop java
- Category
- Java
- Title
- biginteger in java
- Category
- Java
- Title
- code to include layout from java in android
- Category
- Java
- Title
- taking string input in java
- Category
- Java
- Title
- multiple string java
- Category
- Java
- Title
- linux pyspark select java version
- Category
- Java
- Title
- how to create a method java
- Category
- Java
- Title
- long input in JAVA
- Category
- Java
- Title
- how to multiply a number by itself using for loop in java
- Category
- Java
- Title
- how to select a random element from an array in java
- Category
- Java
- Title
- how to make one java class inherit from another
- Category
- Java
- Title
- java s3 images
- Category
- Java
- Title
- java insertion sort
- Category
- Java
- Title
- java read public key from keystore
- Category
- Java