CS Theory

>take a CS class
>suddenly there's a Fibonnaci sequence

Recursion aside why is the Fibonacci sequence so important in CS? There isn't a single class I've been in where we don't end up discussing it.

Other urls found in this thread:

en.wikipedia.org/wiki/Golden_ratio#Relationship_to_Fibonacci_sequence
momath.org/home/fibonacci-numbers-of-sunflower-seed-spirals/
en.m.wikipedia.org/wiki/Fibonacci_retracement
twitter.com/NSFWRedditImage

It's a very simple recursive function that can be used as an example to teach you recursion and optimizing recursive algorithms.

It's not important at all, it's just convenient for examples.

This

Damn. I was hoping for something a little deeper

>why is the Fibonacci sequence so important in CS

It's not that it's important, it's a pertinent mathematical property. In particular, it plays a role in prime numbers, as well as a key part in NP-completeness. I've said too much.

seeing as you didn't even realise that fact on your own, you're a no hoper

> I've said too much.

what did he mean by this? are (((they))) using Fibnoacci Numbers?

...

Recursion is shit stop using it

Brainlet here, is recursion ever a useful tool (outside Academia)?

Makes a lot of algorithms more readable than their iterative counterparts

t. freshman dropout
It appears at least twice in any decent numerical analysis course.

Depending on your field and type of problem.
Some graph traversal algorithms are stupid simple with recursion

Because it's the debian logo and debian is the best os

Lol, we were covering it in computer architecture

It's way more fun when you're fucking with memory directly

Maybe you need to learn to program better.

What's the difference between recursion and loop?

Recursion: when a function keeps calling itself. Easily understandable but a bitch to debug and very hard on resources - might cause a stack overflow. Generally a bad idea, only good in a very few cases (like directory traversal). Most common example is calculating factorials.

Loop: do something n times (for) or keep repeating until a condition is met (while) or keep repeating until a condition is met, but do it at least once (do while).

Hope it helps.

It's to teach recursion. Also don't use recursion it's shit.

>Easily understandable but a bitch to debug and very hard on resources - might cause a stack overflow. Generally a bad idea, only good in a very few cases (like directory traversal).
Get a better compiler.

Recusrive programming is by far the norm in functional programming, where the compiled result ends up being iterative and a single stack frame.

This means having all of the immutability, abstraction, and reasonability of recursive programming, but none of the stack frame overhead.

Recursion is useful in cases where on each iteration of your code, your code has to maintain information in a stack. The advantage of recursion is that the function call stack maintains that information stack for you. For example, if you implemented the normal recursive version of quicksort with only iteration, you would need to keep track of which start and end indexes to scope your sort in on each iteration.

Read this as "your code has to suck cock"

Hahaha.

>cs majors know less about cs theory than math majors

Fibonacci Sequence is also related to the Golden Ratio. The Golden ratio has been found to be aesthetically pleasing, for instance the dimensions of a postcard are designed with the golden ratio, buildings also. Plus Da Vinci designed that picture of the human man with the golden ratio in mind

en.wikipedia.org/wiki/Golden_ratio#Relationship_to_Fibonacci_sequence

Plus then theres the golden spiral, and this is found in nature, such as snails shell, plus the fib sequence describes how sunflower seeds are arranged int the flower head

momath.org/home/fibonacci-numbers-of-sunflower-seed-spirals/

Absolutely. Recursion lets you call a function multiple times in different contexts without using a separate iteration construct (such as a for loop). This often makes for much more elegant code than you'd get otherwise.
Recursion is also great for iterating over graphs, and basically all data structures can be thought of as graphs.

Financial guys use it to predict how far a stock price will fall

en.m.wikipedia.org/wiki/Fibonacci_retracement

A Fibonacci sequence is just a geometric sequence that's trying to be fancy.

Geometric sequences come up all the time.

No I knew it's an easy example which is why I said in the OP recursion aside. I just hoped someone would blow my mind with something about Fibonnaci

>Fibonacci Sequence is also related to the Golden Ratio.

Yes. I took a CS Theory class once, and our Professor showed us a formula for calculating the nth Fibonacci number using integer division with the golden ratio formula.

I think I've seen it being used in compression or cryptography before but that's it.

There are some problems that are a nightmare to solve without recursion like tower of hanoi?