Given a number as ‘num’, and Number of lines as ‘num_of_lines’ where ‘num’ implies the starting number from which the pattern has to be started and ‘num_of_lines’ implies the number of lines that have to be printed. Now, according to the above information, print a pattern as given below.
Input: num = 7, num_of_lines = 4 Output: 7 14 15 28 29 30 31 56 57 58 59 60 61 62 63 Input: num = 3, num_of_lines = 3 Output: 3 6 7 12 13 14 15
- Elements of the first column are the multiple of the previous element in that column.
- No. of elements in each row is the twice of the no. of elements in the previous row.
- Also, to generate next element in the row, add 1 to previous element of that row.
So, start a loop from 0 to num_of_lines-1, to take care of the number of rows to be printed and another loop inside the first loop, from 0 till limit-1, the limit will be initialized to 1, and its value is increased exponentially. Now inside the loop, just increase the number by 1 to print the next number of that row.
3 6 7 12 13 14 15
- Program to print numeric pattern
- Program to print the pattern "GFG"
- Program to print the pattern ‘D’
- Program to print pattern
- Program to print the pattern 'G'
- Program to print the given Z Pattern
- Program to print the given H Pattern
- Program to print V and inverted-V pattern
- Program to print interesting pattern
- Program to print pyramid pattern
- Program to print Step Pattern
- Program to Print the Trapezium Pattern
- Program to print the Zigzag pattern
- Program to print the Ladder Pattern
- Program to print number pattern
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.