answersLogoWhite

0

Maybe not the most elegant way but it works.

public class Main {

public static void main(String[] args) {

int count = 0;

int number = 2;

while(count < 10) { int c=0;

for(int i = 2; i < number ; i++)

{

if (number%i == 0)

{

c=1;

break;

}

}

if(c==0)

{

System.out.print(number + " ");

count++;

}

number++;

}//end of while

} //end of main

} //end of class

User Avatar

Wiki User

15y ago

What else can I help you with?

Related Questions

Write an algorithm to print sum of all even numbers?

Start print "the sum of all even numbers is infinite" end


How to Write a psuedocode algorithm to read in three numbers and print the highest and lowest number?

read num1 read num2 sum = num1 num2 print highest value


Write a java script program to print first ten odd natural numbers in C?

Q.1 Write a program to print first ten odd natural numbers. Q.2 Write a program to input a number. Print their table. Q.3 Write a function to print a factorial value.


Can you write an algorithm to find the beast numbers?

maybe


How do you write a program to print the first n multiples of 7?

Algorithm: multiples input: two positive integers, m and n output: print first n multiples of m i = m; for j = 1 to n print i i = i + m; next j


Write an algorithm to check whether a number is a prime number or not?

You can write out this algorithm. This will then be programmed into the device to make determining prime numbers easier.


Write a algorithm to print all even numbers in descending order?

AnswerIf A=10, B=2... Then the algoritm is :-STEP1 : START.STEP2 : A=10.STEP3 : B=02.STEP4 : C=A-B.STEP5 : PRINT C.STEP6 : STOP.AnswerYou cannot print every even number in descending order, because there is no greatest even number. Or you want something like this: infinityinfinity-2infinity-4Answerstep 1: start step 2: Input Nstep 3: If N


How do you write and draw an algorithm in flowchart for Add 2 and 4 and print the sum?

2+4


Write an algorithm or draw a flowchart to display numbers from 100 down to 10?

n=100 loop until n = 9 print n n = n -1 end loop


Write algorithm and draw flowchart to find the sum of even numbers?

jgfujtf


Write an Algorithm for multiplication table of an integer?

int firstNumber,secondNumber for(firstNumber = min; firstNumber &lt;= max; firstNumber++); { for(secondNumber = min; secondNumber &lt;=max; secondNumber++); int result firstNumber * secondNumber; }


How write algorithm for finding the sum first ten even number?

Sum = 0 For N = 1 to 10 Sum = Sum + 2*N Next N Print Sum