I solved the problem using consecutive differences and detecting when the difference becomes constant. The method works correctly for small enough inputs, including the examples given and some sequences I generated. However, with larger numbers the differences are no longer computed correctly, and they appear not to be constant when they actually are. As a result, the program reports that the sequence is smart when it is not.
I guess it is some king of overflow - for bigger numbers the differences appear larger than they are. I am using unsigned long long to accommodate the 64 bit numbers. Ideas how to deal with the possible overflow?
Any help will be greatly appreciated
Here is my code (the problem occurs as early as the first call to finddiffs):