10 Days of Basic Programming, Day 6: Input/Output, recursion and some exercises

Acid_Snake

I like beer.

13 Responses

  1. solid_gabe136

    The way i first understood recrsive fxn is to look at a function that is recursive itself, for instance n! Can be easilily written with recursion, so technically calculatng e might require an n! Fxn or importing some math library

  2. NoSpam

    10 print “Wo”
    20 print “lo”
    30 goto 20
    RUN

  3. k3nn

    –the above function that counts from 0 to 10 has a mayor flaw in it, can you tell what it is?

    if you call recursive using a number > 10 as the first value, it will turn into an infinite loop.

    • k3nn

      recursiveCount(11); <– infinite loop

      • Acid_Snake

        that is indeed correct.

        • k3nn

          woohoo… f.i.r.s.t.! but i still haven’t figured out how to do the Big Oh(log n)…the only thing i know that could do that fast is 2^n using shifts instead of actual multiplication.hmmm…

          • Acid_Snake

            Yeah but I’m not talking about powers of 2, I’m talking about any power. You have to make an algorithm pow(b, n) that calculates b^n in logarithmic time. Replacing multiplication with shifts doesn’t exactly change the complexity and cost of the algorithm.

  4. nebu_187

    i just realised, u have to be a total geek to be a good programmer, no offense but whitout being totally obsessed with programming and having to much free time it is something u will never achieve to do well. if it is your proffesion its totally different of course. Ur 10 days of programming made me realise: ill just stick 2 gaming

    • Yatto

      No you don’t have to ! Here, Snake is teaching the basic of “how you have to think to program” (with some drops of C language here and there), but you can use these basic programming skills to program something with a WYSIWYG interface, where you draw a window, drop some buttons, then add some light lines of code, just as you would do in VIsual Basic for Applications, when you create a macro for MS Excel.
      In France, since 2014, children are taught basic programming skills (on their graph calculator mostly) from their 2nd or 3rd year of secondary school (when they’re 13 years old) and most of them love it because it allows them to make little programs to help them during maths tests ; and if they do these kind of programs, they are allowed, the teacher adapts the tests to focus on understanding. It works.

      So if you’re reading this, please consider trying to program on something light if you want to do some basic stuff. A graphic calculator (TI-83+ / Casio 25+ for example) is great for a beginner. But you can start with C or Python on PC as well, feel free to experiment.