0

# Without array Java code to print prime numbers from 1 to 100?

Updated: 12/13/2022

Wiki User

14y ago

public class Primes {

public static void main(String[] args) {

for(int i = 2; i < 100; i++) {

if(isPrime(i)) {

System.out.println(i);

}

}

}

public static boolean isPrime(int n) {

if(n 0) return false;

}

return true;

}

}

}

Wiki User

14y ago

Earn +20 pts
Q: Without array Java code to print prime numbers from 1 to 100?
Submit
Still have questions?
Related questions

### How do you print a number as on or more literal words in PHP?

Create an array like so \$numbers = array(); \$numbers['0'] = "ZERO"; \$numbers['1'] = "ONE"; and so on.. till you decide that's enough then to print it, echo the array with the desired key like so.. Example I print 5 in words echo \$numbers['5']; which would print FIVE Good luck

### Program to print all the even numbers of an array in visual basic?

find even number in array

Yes but why.

### Write a program to print first 100 alternative prime numbers?

This would require some computer knowledge. It can make it easier to find out the prime numbers without figuring it out in your head.

### Write a java program to print the result in the series?

If you have the series stored in an array, you loop through the array and print each array element in turn. Another possibility is to print out the numbers in the series as you generate them. In that case, you may not need to store anything (depending on the series, of course).

### Program for print prime all number from 1 to 100 in foxpro?

Prime numbers are numbers that are only divisible by themselves and the number 1. You can write a program to print all prime numbers from 1 to 100 in FoxPro.

### Write a c program to find the maximum of two numbers and print out with its position?

maxValue = function (array) {mxm = array[0];for (i=0; i&lt;array.length; i++) {if (array[i]&gt;mxm) {mxm = array[i];}}return mxm;}; i don't know

### How do you print array variable without using array subscripts?

Well the most prolific answer to this query would be the use of pointers.Use a pointer and allocate it to the array of interest and start printing.

### How do you write a program to print prime numbers from 1 to 100 in PHP?

&lt;pre&gt; &lt;?php \$limit = 100; \$primeList = array(); for(\$i = 2; \$i &lt; round(sqrt(\$limit)); \$i++) { foreach(\$primeList as \$num) { if(\$i%\$num 0)) continue 2; } \$prime[] = \$i; } print_r(\$prime); ?&gt; &lt;/pre&gt; Based on Sieve of Erathosthenes. See the related link for further information.

### How do you write a program which reads a list of ten numbers and print the list in reserve order in c program?

The simplest way is probably to read the numbers into an array and then prints each element of the array starting at the last one and moving backwards.

### Write down programin GWBASIC to sort numbers in an array?

10 cls 20 end 30 next 40 print

### You want to write a simple without using pointer or array c program which will print greatest number when you give 20 number?

i want to write a simple without using pointer or array c program which will print greatest number when i give 20 number .........How far have you gotten so far?