Given a sequence of digits (0-9), predict what the next digit is going to be? Or predict if it’s going to be even or odd?

Ex: 0, 5, 3, …, 6, 9 (total of 6000 or something)

Ex: 0, 0, 1, …, 1, 0 (series of 0s and 1s representing odds and evens)

While predicting, it doesn’t need to look back at the whole data, instead it should just look back a fixed length of digits (like 10, 15).

What is the best way to formulate this problem? Is it regression or classification?

And what algorithm should I use? (Please also include the activation function, optimizer and loss function to be used)

If possible, share some code in tensorflow or keras.