Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What would be a good general algorithm for approaching integer sequence problems?

Say the input will always be the same number N of numbers (e.g., 5) and assume the integers actually have a mathematical relation (no lengths of the numbers 'one', 'two', days in the nth month, etc.). The output would be either the next integer and the rule discovered or a message that no rule could be detected. I was thinking to have in one-two-three order, a module that tries to find arithmetic sequence rules by doing sums and/or differences between numbers adjacent, one away, two away, etc. looking for patterns, then having a module focused on geometric sequences by multiplying and/or dividing in the same way, and then, if there is a general approach, a module for detecting recursive sequences.

Thanks!

like image 817
mring Avatar asked Nov 26 '25 21:11

mring


1 Answers

The On-Line Encyclopedia of Integer Sequences solves precisely this problem :-)

like image 180
aioobe Avatar answered Nov 28 '25 17:11

aioobe