mercredi 6 avril 2016

Can I find patterns in a list of numbers - Python

So I'm pretty new to python, and I pretty sure this would be an algorithm. Anyways, I was wondering if it is possible to take a list of numbers eg.

lst = [1, 1, 2, 3, 5, 8, 13, 21, 34]

And use an algorithm to figure out that the pattern is: the last number + the current one and then keep going and add the next number:

    lst.append(x) # x being the next number which is 55

Possibly an algorithm that could be applied to any list of numbers

Thanks in advace!

Aucun commentaire:

Enregistrer un commentaire