write a program to print the following pattern of numbers

write a program to print the following pattern of numbers
1 2 3 4 5
5 7 9 11 13
13 16 29 22 25
25 29 33 37 41
1
2
3
4
5
6
#include <iostream>
int main ()
{
    std::cout << "1 2 3 4 5\n5 7 9 11 13\n13 16 29 22 25\n25 29 33 37 41\n";
    return 0;
}


Done. It took me hours to do it.
...made me smile.
Well, first off; do you see a special pattern in the sequence? Are you able to make the fifth row (without a program)? And btw, the 3rd number on the 3rd row should (most likely) be 19, not 29. It's a lot easier to help you if you show us what you have so far, and what you don't understand/need help with.
Last edited on
i have to do it with "nested for" :/
As I said, what part of the assignment is it you don't understand?
See, firstly, figure out the logic and algorithm. What is the relation between the common difference between the numbers in one line, AND the line number? That is the first thing you have to figure out. If you do that, we can help you further. No use just giving you the program...
Topic archived. No new replies allowed.