{"id":9218,"date":"2021-09-30T17:30:10","date_gmt":"2021-09-30T12:00:10","guid":{"rendered":"https:\/\/python-programs.com\/?p=9218"},"modified":"2021-11-22T18:33:33","modified_gmt":"2021-11-22T13:03:33","slug":"python-program-to-print-numbers-in-a-range-1upper-without-using-any-loops-or-by-using-recursion","status":"publish","type":"post","link":"https:\/\/python-programs.com\/python-program-to-print-numbers-in-a-range-1upper-without-using-any-loops-or-by-using-recursion\/","title":{"rendered":"Python Program to Print Numbers in a Range (1,upper) Without Using any Loops or by Using Recursion"},"content":{"rendered":"

Interested in programming and want to excel in it by choosing the short ways. Then, practicing with the available Java Program list<\/a> is mandatory.<\/p>\n

If we examine closely at this problem, we can see that the concept of “loop” is to track some counter value, such as “i=0″ till I = higher”. So, if we aren’t permitted to use loops, how can we track something in Python?
\nOne option is to use ‘recursion,’ however we must be careful with the terminating condition. Here’s a solution that uses recursion to output numbers.<\/p>\n

Examples:<\/strong><\/p>\n

Example1:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

Enter some upper limit range = 11<\/pre>\n

Output:<\/strong><\/p>\n

The numbers from 1 to 11 without using loops : \r\n1\r\n2\r\n3\r\n4\r\n5\r\n6\r\n7\r\n8\r\n9\r\n10\r\n11<\/pre>\n

Example2:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

Enter some upper limit range = 28<\/pre>\n

Output:<\/strong><\/p>\n

The numbers from 1 to 28 without using loops : \r\n1\r\n2\r\n3\r\n4\r\n5\r\n6\r\n7\r\n8\r\n9\r\n10\r\n11\r\n12\r\n13\r\n14\r\n15\r\n16\r\n17\r\n18\r\n19\r\n20\r\n21\r\n22\r\n23\r\n24\r\n25\r\n26\r\n27\r\n28<\/pre>\n

Program to Print Numbers in a Range (1,upper) Without Using any Loops\/Recursive Approach<\/h1>\n

Below are the ways to print all the numbers in the range from 1 to upper without using any loops or by using recursive approach.<\/p>\n