Recursion and stuff…
Welcome to my brand new post. This time I want to show how to use recursion in a very simple function. We already did this in an iterative way and I thought it would be nice to show how to do it in the recursive way. I’m talking about the fibonacci numbers.
Here is a short video explaining an example of the recursive funcition to calculate the fibonacci number of a given index.
Check also this resources to know when to use recursive functions.
http://www.cplusplus.com/articles/D2N36Up4/
In this article the dicussion is set around when to use a recursive function. The answer can’t be easier: when a function calls itself.
Personally, I like cplusplus.com I’ve found useful articles and discussions about many topics. Believe me there’s a post for your questions there.
Here’s another piece of information from cplusplus.com:
http://www.cplusplus.com/forum/articles/2231/
]]>
This post is about mastery number 18. The use of nested conditionals. I explained a simple example in the next video but I would also like to share other resources such as tutorialspoint.com’s exlanation of nested conditionals.
Take a look to it.
http://www.tutorialspoint.com/cplusplus/cpp_nested_if.htm
Another video I watched is about if/else interaction and nesting those loops.
I think the most important conditional that allows nesting is the if. You can read a nested bunch of if’s as: If this is true, the perform this if this is true, perform the next if this is true and so on… You could use opertaros such as && and || (and or) to simplify some nested conditionals and make your code easier.
]]>Well I got helped and I read Carlo’s solution. The thing is that my answer should work but i had a little problem with the way my number are added.
]]>
This is a cool WSQ, in fact this was one of my favorites. Why? Because at first it was hard, nevertheless I did it! Honestly, it took me around two hours to finish this WSQ.
Any way, here is my code:
https://github.com/OctavioIRG/TC1017/commit/a2fc843ad2b3ba057b40c4b2f2becaebdf9f12f5
I thought it would be cool to show the user how the babilonian method starts aproximates to the actual value of the square root, thus I decided to print each cycle. The cycle breaks when the last and current value of the squareroot is the same.
]]>The purpose of this post I to tell you, my dear reader, my experience with Scilab. In a few words; Scilab is a geat tool, I read the manual and performed almost all the examples. One of the things that surprised me was the 3D Plot tool. More over, it’s pretty awesome to have all the tools in a single window. You can plot, calculate, programm and more in a single platform.
I’m guessing this tool has a enormous potential that unfortunately I can’t use right now but as Ken wrote in the WSQ, I will probably use this tool through my carrer. Thank you Ken!
]]>
Hello everybody, this time I found the instructions confusing, I mean, I tried my best interpreting the instructions and I came up with this:
https://github.com/OctavioIRG/TC1017/blob/master/WSQ-s/eu.cpp
I hope its rigth, I coulnd’t make it print only once the number But it does give you the wirte decimals up to 15 digits after the decimal point. I guess that the varaible I use in the factorial functions isn’t big enough.
Beside those two mistakes (double printing and wrong decimals after 15 digits) the programm works. I did it with out more help than the equation to calculate e so I guess it was a good try.
]]>Yeah… so, many things to do and lack of organization. The worst combination ever. I haven’t finished my final project and I allmost give up with it last week. The only thing I am doing well is the WSQ work.
In the last picture you can see that at the moment of writting these lines I was on supposed to be doing this exact WSQ.
Good luck everybody with your final exams.
]]>