{"id":6103,"date":"2017-01-08T12:23:31","date_gmt":"2017-01-08T12:23:31","guid":{"rendered":"https:\/\/www.testingdocs.com\/questions\/?p=6103"},"modified":"2025-03-22T05:24:43","modified_gmt":"2025-03-22T05:24:43","slug":"flowchart-to-print-n-natural-numbers-in-reverse-order","status":"publish","type":"post","link":"https:\/\/www.testingdocs.com\/questions\/flowchart-to-print-n-natural-numbers-in-reverse-order\/","title":{"rendered":"Flowchart to print n natural numbers in reverse order"},"content":{"rendered":"<h2>Flowchart to print n natural numbers in reverse order<\/h2>\n<p>In this tutorial, we will create a RAPTOR flowchart to print n natural numbers in reverse order. The flowchart would prompt the user to enter the number. The flowchart uses a recursive procedure to print the numbers in reverse order.<\/p>\n<h3>Recursive procedure<\/h3>\n<p>A recursive procedure call is a procedure call that calls the procedure itself.\u00a0 In this example, the main flowchart prompts the user for the number. The main then invokes the procedure print. The print()\u00a0 procedure is recursive.<\/p>\n<p>main invokes print with -&gt; print(n)<\/p>\n<p>print() invokes -&gt; print(n-1)<\/p>\n<p>To know more on the RAPTOR procedure, follow the link:<\/p>\n<p><strong><a href=\"https:\/\/www.testingdocs.com\/procedure-in-raptor-flowcharts\/\">https:\/\/www.testingdocs.com\/procedure-in-raptor-flowcharts\/<\/a><\/strong><\/p>\n<h3>Flowchart<\/h3>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-6106 size-full\" title=\"numbers in reverse order\" src=\"https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Raptor-Recursive-Procedure-.png\" alt=\"numbers in reverse order\" width=\"1829\" height=\"1009\" srcset=\"https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Raptor-Recursive-Procedure-.png 1829w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Raptor-Recursive-Procedure--300x166.png 300w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Raptor-Recursive-Procedure--1024x565.png 1024w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Raptor-Recursive-Procedure--768x424.png 768w, https:\/\/www.testingdocs.com\/questions\/wp-content\/uploads\/Raptor-Recursive-Procedure--1536x847.png 1536w\" sizes=\"auto, (max-width: 1829px) 100vw, 1829px\" \/><\/p>\n<p>&nbsp;<\/p>\n<h3>Base Case<\/h3>\n<p>When we work with recursive procedures we need to take care of two things. Base case and convergence of the problem that is being solved.<\/p>\n<p>The base case is the halting case. We need to stop the recursion, otherwise, there is a risk of infinite recursion and unwanted errors in the flowchart. Infinite recursion is a recursion that doesn&#8217;t end without any halting case.\u00a0 In the example, the recursion stops when n == 0. We can see the call stack of the recursion in the left activity window.<\/p>\n<p>Convergence is another requirement for the recursive function or procedure. We need to converge the problem that we solve using recursion. In this example, the next recursive call converges the problem by calling the smaller n i.e n-1 , n-2 , n-3 etc with the base n==0.<\/p>\n<h3>Sample Output<\/h3>\n<p>Let&#8217;s run the flowchart with sample test cases to verify that it&#8217;s working as intended. If you find that the flowchart is not working as intended in the testing, we may need to verify and debug the flowchart.<\/p>\n<p>Debugging a flowchart: <strong><a href=\"https:\/\/www.testingdocs.com\/debugging-a-raptor-flowchart\/\">https:\/\/www.testingdocs.com\/debugging-a-raptor-flowchart\/<\/a><\/strong><\/p>\n<p>Output<\/p>\n<p>Enter number : 5<\/p>\n<p>5\u00a0\u00a0 4\u00a0\u00a0 3\u00a0\u00a0 2\u00a0\u00a0 1<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Flowchart to print n natural numbers in reverse order In this tutorial, we will create a RAPTOR flowchart to print n natural numbers in reverse order. The flowchart would prompt the user to enter the number. The flowchart uses a recursive procedure to print the numbers in reverse order. Recursive procedure A recursive procedure call [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[187],"tags":[208],"class_list":["post-6103","post","type-post","status-publish","format-standard","hentry","category-flowchart","tag-mathematics","has-post-title","has-post-date","has-post-category","has-post-tag","has-post-comment","has-post-author",""],"_links":{"self":[{"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/posts\/6103","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/comments?post=6103"}],"version-history":[{"count":18,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/posts\/6103\/revisions"}],"predecessor-version":[{"id":27158,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/posts\/6103\/revisions\/27158"}],"wp:attachment":[{"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/media?parent=6103"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/categories?post=6103"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.testingdocs.com\/questions\/wp-json\/wp\/v2\/tags?post=6103"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}