TO PRINT LUCKY NUMBERS

Page 1 of 1

11 Replies - 10268 Views - Last Post: 23 February 2010 - 08:36 AMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=69070&amp;s=41e51e725dce2c593c49fb1b1414f75e&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

#1 priya_lorha

Reputation: 6
• Posts: 82
• Joined: 02-August 08

TO PRINT LUCKY NUMBERS

Posted 25 October 2008 - 09:24 PM

I have no idea about the logic help!!!! plz

the out will be
[1, 3, 7, 9, 13, 15, 21, 25, 27, 31, 33, 37, 43, 45, 49]
Is This A Good Question/Topic? 0

Replies To: TO PRINT LUCKY NUMBERS

#2 absynthe

• DIC Tease

Reputation: 35
• Posts: 2,844
• Joined: 20-September 08

Re: TO PRINT LUCKY NUMBERS

Posted 25 October 2008 - 11:11 PM

System.out.print(" 1, 3, 7, 9, 13, 15, 21, 25, 27, 31, 33, 37, 43, 45, 49 ");

This post has been edited by absynthe: 25 October 2008 - 11:13 PM

#3 gabehabe

• GabehabeSwamp

Reputation: 1431
• Posts: 11,006
• Joined: 06-February 08

Re: TO PRINT LUCKY NUMBERS

Posted 26 October 2008 - 09:56 AM

I think you're looking to output odd numbers~

Try this:

for (int i = 1; i < 50; i += 2) {
System.out.print(i.toString() + " ");

#4 pbl

• There is nothing you can't do with a JTable

Reputation: 8378
• Posts: 31,956
• Joined: 06-March 08

Re: TO PRINT LUCKY NUMBERS

Posted 26 October 2008 - 08:46 PM

gabehabe, on 26 Oct, 2008 - 09:56 AM, said:

I think you're looking to output odd numbers~

Try this:

for (int i = 1; i < 50; i += 2) {
System.out.print(i.toString() + " ");

NO: 11, 17, 23, ... are missing must be something else

#5 westforduk

Reputation: 24
• Posts: 140
• Joined: 16-August 07

Re: TO PRINT LUCKY NUMBERS

Posted 26 October 2008 - 08:47 PM

I think the program is supposed to output random numbers between 1-49 and all being unique.
Not sure though.

Actually maybe not.

Nevermind.

This post has been edited by westforduk: 26 October 2008 - 08:48 PM

#6 pbl

• There is nothing you can't do with a JTable

Reputation: 8378
• Posts: 31,956
• Joined: 06-March 08

Re: TO PRINT LUCKY NUMBERS

Posted 26 October 2008 - 09:19 PM

If priya_lorha tells us what a "lucky number is may be we can help

#7 SanjitVignesh

Reputation: 0
• Posts: 17
• Joined: 19-September 08

Re: TO PRINT LUCKY NUMBERS

Posted 26 October 2008 - 10:27 PM

The series goes in this order, the numbers are from 1 to 50.

The incrementation goes like this, +2, +4, +2,+4, +2, +6 and so on. Hope this clears the logical part.

I don't know how to put the code for it.

This post has been edited by SanjitVignesh: 26 October 2008 - 10:28 PM

#8 pbl

• There is nothing you can't do with a JTable

Reputation: 8378
• Posts: 31,956
• Joined: 06-March 08

Re: TO PRINT LUCKY NUMBERS

Posted 27 October 2008 - 05:19 PM

SanjitVignesh, on 26 Oct, 2008 - 10:27 PM, said:

The series goes in this order, the numbers are from 1 to 50.

The incrementation goes like this, +2, +4, +2,+4, +2, +6 and so on. Hope this clears the logical part.

And what is the logic about 2,4,2,4,2,6 ? What is the next number

#9 amitdhar

Reputation: 3
• Posts: 49
• Joined: 01-February 08

Re: TO PRINT LUCKY NUMBERS

Posted 28 October 2008 - 05:56 AM

The logic is, from the series from 1 to 100 remove all the 2nd numbers, i.e.
1,3,5,7,9,11, ......

From the remaining numbers remove every third number i.e.
1,3,7,9,......

From the remaining remove every 4th number i.e.
1,3,7,......

this way the logic will proceed....

#10 Gloin

• Expert Schmexpert...

Reputation: 235
• Posts: 4,489
• Joined: 04-August 08

Re: TO PRINT LUCKY NUMBERS

Posted 28 October 2008 - 06:08 AM

Lucky numbers or not, I think we have to consider amitdhar the winner here.. And the prize is.. Sorry, no prize..

Anyways, you use a boolean array[100], I'll use coffee..

Reputation:

Re: TO PRINT LUCKY NUMBERS

Posted 13 February 2010 - 12:33 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38..
(reject the +2 position no.s from the above series)
1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51 53 55 57 59 61 63 65 67 69 71 73.
(reject the +3 position no.s from the above series)
1 3 7 9 13 15 19 21 25 27 31 33 37 39 43 45 49 51 55 57 61 63 67 69 73..
(reject the +4 position no.s from the above series)
1 3 7 13 15 19 25 27 31 37 39 43 49 51 55 61 63 67 73...
(reject the +5 position no.s from the above series)
1 3 7 13 19 25 27 31 39 43 49 51 61 63 67 73...
(reject the +6 position no.s from the above series)
1 3 7 13 19 27 31 39 43 49 61 63 67 73...
(reject the +7 position no.s from the above series)
1 3 7 13 19 27 39 43 49 61 63 67...
(reject the +8 position no.s from the above series)
1 3 7 13 19 27 39 49 61 63 67...
(reject the +9 position no.s from the above series)
1 3 7 13 19 27 39 49 63 67...
(reject the +10 position no.s from the above series)
1 3 7 13 19 27 39 49 63 ..

Reputation:

Re: TO PRINT LUCKY NUMBERS

Posted 23 February 2010 - 08:36 AM

Saswat, on 13 February 2010 - 11:33 AM, said:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38..
(reject the +2 position no.s from the above series)
1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51 53 55 57 59 61 63 65 67 69 71 73.
(reject the +3 position no.s from the above series)
1 3 7 9 13 15 19 21 25 27 31 33 37 39 43 45 49 51 55 57 61 63 67 69 73..
(reject the +4 position no.s from the above series)
1 3 7 13 15 19 25 27 31 37 39 43 49 51 55 61 63 67 73...
(reject the +5 position no.s from the above series)
1 3 7 13 19 25 27 31 39 43 49 51 61 63 67 73...
(reject the +6 position no.s from the above series)
1 3 7 13 19 27 31 39 43 49 61 63 67 73...
(reject the +7 position no.s from the above series)
1 3 7 13 19 27 39 43 49 61 63 67...
(reject the +8 position no.s from the above series)
1 3 7 13 19 27 39 49 61 63 67...
(reject the +9 position no.s from the above series)
1 3 7 13 19 27 39 49 63 67...
(reject the +10 position no.s from the above series)
1 3 7 13 19 27 39 49 63 ..

hey someone give the java program code to run this lucky no. process....