Putting codes in order......
I have been asked to generate prime numbers between 50 to 60 using snippets being provided. But the snippets are in jumbled order and I am required to put that snippet in order to be able to run this code.....but I find it as herculean task....
further adding to the soln.....the output would be
50 = 1 2 5
51 = 1 3 17
52 = 1 2 13
53 = 1 53
54 = 1 2 3
55 = 1 5 11
56 = 1 2 7
57 = 1 3 19
58 = 1 2 29
59 = 1 59
60 = 1 2 3 5
please help me.....
Code :
public class prime
{
public static void main(String[] args)
{
int i = 0 , j , k , p ;
j = 1 ;
p = 0 ;
for(i = 51 ; i < 62 ; i ++) {
k = 2 ;
while(k <= (j-1)) {
if(j % k == 0)
p ++ ;
else {
j ++ ;
k ++ ; }
if(j == 1 || j == 2 || j == 3)
} while( j <= i ) ; }
if((i - j) % j == 0 ) {
System.out.println(j) ;
do {
if(p == 0)
System.out.println(j) ; }}
System.out.println(i-1) ;
Re: Putting codes in order......
Help you in what? What's your question?
Re: Putting codes in order......
I have to rearrange those syntax in the program in correct order to generate answer as mentioned.....
Re: Putting codes in order......
What's the original order and syntax? What have you tried so far? What problems are you facing? If there are errors/exceptions, paste here. If it's giving different results, provide here with the test cases you've applied.