Question bank › Recursion
Dsa Recursion Warm-up

The Mirror Count

Write a recursive function to print a shrinking and expanding sequence of numbers. Given N, print N, N-1, ... down to 1, and then back up to N, all on one line separated by spaces. Input Format: A single integer N. Output Format: A sequence of integers separated by spaces. Example: Input: 3 Output: 3 2 1 2 3

Key concepts

recursionmath

Practise this out loud — free

Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.

🎙 Practise this question now
Part of InterviewLab's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.