I have an assignment where I am given a sequence and I must turn the user's input (int) into that sequence. For example:
number : 2
The sequence starting at 2 is : 2 4 16 37 58
The sequence is: 2^2=4, 4^2=16, 1^2+6^2=37, 3^2+7^2=58, etc....
how would I compute the sequence? and if the user enters a 2 digit number would I just assign them n1 and n2?
This is what I have so far [c++]:
int n1, n2, n, sum=0;
n=pow(n1, 2)+pow(n2, 2);
for(n=1; n<162; ++n) //162 is the largest number b/c 9^2+9^2=162
//when i run it it gives me a long line of integers that go up to 12880