Crazy Numbers Pattern Challenge

Ninja enjoys arranging numbers in a sequence. He plans to arrange them in 'N' rows such that:

  • The first row contains 1 number.
  • The second row contains 2 numbers.
  • The third row contains 3 numbers, and so on.

The numbers are placed in increasing order with an absolute difference of 1. Starting from 1 and continuing until 9, after which the sequence restarts from 1.

Input:

The first line contains 'T', representing the number of test cases. 
Each test case has a single integer 'N', indicating the number of rows.

Output:

For each test case, output the integers in the pattern for the next 'N' lines.

Example:

Input:
1 
4
Output:
   1 
23
456
7891

Constraints:

  • 1 <= T <= 10
  • 1 <= N <= 500

Note: The expected output is printed automatically; focus on implementing the function logic.

AnswerBot
4mo

Arrange numbers in a sequence in 'N' rows with increasing order and repeating after 9.

  • Iterate through each test case and for each row, print numbers in increasing order with a loop.

  • Keep track of the c...read more

Saurabh Mishra
9mo
int N = 5; int counter = 1; for (int i = 1; i 9) counter = 1; } Console.WriteLine(); } Here Time complexity TC=> O(N^2) And SC => O(1)
Help your peers!
Select
Add answer anonymously...

Nagarro Software Developer interview questions & answers

A Software Developer was asked 3mo agoQ. Design and implement a data structure for Least Recently Used (LRU) cache. It sh...read more
A Software Developer was asked 3mo agoQ. Given the root of a binary search tree, and an integer k, return the kth smalles...read more
A Software Developer was asked 5mo agoQ. What is abstraction in Java?

Popular interview questions of Software Developer

A Software Developer was asked 3mo agoQ1. Design and implement a data structure for Least Recently Used (LRU) cache. It sh...read more
A Software Developer was asked 3mo agoQ2. Given the root of a binary search tree, and an integer k, return the kth smalles...read more
A Software Developer was asked 5mo agoQ3. What is abstraction in Java?
Nagarro Software Developer Interview Questions
Stay ahead in your career. Get AmbitionBox app
play-icon
play-icon
qr-code
Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+

Reviews

10L+

Interviews

4 Cr+

Salaries

1.5 Cr+

Users

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2025 Info Edge (India) Ltd.

Follow Us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter
Profile Image
Hello, Guest
AmbitionBox Employee Choice Awards 2025
Winners announced!
awards-icon
Contribute to help millions!
Write a review
Write a review
Share interview
Share interview
Contribute salary
Contribute salary
Add office photos
Add office photos
Add office benefits
Add office benefits