Do you understand the pattern in that sequence of numbers? Do you understand the relationship each number has to the previous numbers? Do you understand how to generate the next number in that sequence?
You need to understand what it is you're trying to write code for, before you can write the code.
EDIT: And stop spamming the forums with multiple threads for the same question.
When you have a series of numbers and are looking for some orderly pattern one way of finding a possible pattern is to get the (finite) difference.
10 11 13 16 20 25 gives
1 2 3 4 5
So we have a pattern, this time anyway, and if it all runs to plan the next number will be 25 + 6 = 31. Of course, the next number might be -1729, there's nothing to say it couldn't be, but people allocating marks generally can't cope with a smartarse (ass?) so best go for 31.
That's half the job done.
Edit: More than half actually because you don't have to predict the next number, just account for the one's you have.
Here's something that uses a nested for loop and outputs those values:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
#include <iostream>
int main()
{
int vals[] = {10, 11, 13, 16, 20, 25};
for ( int x = 0; x < 10; x++)
{
for (int y = 0; y < 10; y++)
{
std::cout << vals[x+y] << ' ';
if (x+y == 5) return 0;
}
}
}
#include <iostream>
usingnamespace std;
int main()
{
int p[] = { 11, -165, 935, -2475, 3374, -960, 7200 };
for ( int x = 0; x < 7; x++ )
{
int y = 0;
for ( int k = 0; k < 7; k++ )
{
y = x * y + p[k];
}
cout << y / 720 << " ";
}
}