*
The moose likes Programming Diversions and the fly likes find the next number in the series Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Other » Programming Diversions
Bookmark "find the next number in the series" Watch "find the next number in the series" New topic
Author

find the next number in the series

Myke Enriq
Ranch Hand

Joined: Feb 13, 2012
Posts: 106
Which one of the numbers in the series is wrong, and should be replaced?
2 - 4 - 8 - 16 - 20 - 22 - 44 - 46
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

20.

It should be 32.

The sequence is 2^n mod 42.
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11161
    
  16

Paul Clapham wrote:20.

It should be 32.

The sequence is 2^n mod 42.

Then how can 46 be valid?


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Umm... good question. 46 is still congruent to 256 mod 42, though.
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

past 4 hours I am thinking of this... no luck till now... let me try further ;)
Matthew Brown
Bartender

Joined: Apr 06, 2010
Posts: 4343
    
    8

Change to 16 to 10. I'll leave the justification for now, but it's not a very complicated sequence.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Oh yeah, it's A099942. Pity, I was kind of attached to my "42" idea.
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Matthew Brown wrote:Change to 16 to 10.

Hmm then I can tell the solution...
+2 next *2 => then next element is 92...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: find the next number in the series
 
Similar Threads
Indian cricket team in Australia
Head Rush AJAX
laptop features...
India Vs Pak one day series
Whats the best computer game you played?