Algorithm to find the next number in a sequence

Posted by Ben Shelock on Stack Overflow See other posts from Stack Overflow or by Ben Shelock
Published on 2010-03-17T19:21:28Z Indexed on 2010/03/17 19:31 UTC
Read the original article Hit count: 210

Filed under:
|
|

Ever since I started programming this has been something I have been curious about. But seems too complicated for me to even attempt.

I'd love to see a solution.

1, 2, 3, 4, 5    // returns 6 (n + 1)
10, 20, 30, 40, 50   //returns 60 (n + 10)
10, 17, 31, 59, 115  //returns 227 ((n * 2) - 3)

© Stack Overflow or respective owner

Related posts about numbers

Related posts about sequence