Mintoris Forum

Author Topic: 99 Bottles of Recursion  (Read 1974 times)

zakerytclarke

  • Sr. Member
  • ****
  • Posts: 195
99 Bottles of Recursion
« on: Jul 03, 2016, 03:18 PM »
This program demonstrates how you can use recursive function calls to create a non-infinite loop. For anyone interested, the run time is roughly equivalent to running the program implemented in a while loop.

zakerytclarke

  • Sr. Member
  • ****
  • Posts: 195
Re: 99 Bottles of Recursion
« Reply #1 on: Nov 17, 2016, 01:34 PM »
I recently Tehran this program and it doesn't output all 99 values. It prints the Roman numeral 2 and then counts down from 34. Any ideas why?

Chuck

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1899
Re: 99 Bottles of Recursion
« Reply #2 on: Nov 18, 2016, 04:29 AM »
Oh, yeah. I put a limit on the text screen size. Lots of text on the screen slows everything down. I can bump up the limit if it's a problem.

zakerytclarke

  • Sr. Member
  • ****
  • Posts: 195
Re: 99 Bottles of Recursion
« Reply #3 on: Nov 20, 2016, 06:39 PM »
It's not a problem for me, I was just curious what had changed.

sraffens

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 220
Re: 99 Bottles of Recursion
« Reply #4 on: Feb 01, 2017, 12:05 AM »
I changed the program with only 2 print statements with recursion and the program is faster.

It when from 1 second to .65 seconds not a lot faster but if you have a lot of printing try changing the way you print.

Scott