Click here to Skip to main content
15,887,249 members
Home / Discussions / C#
   

C#

 
AnswerRe: video streaming Pin
kburman624-Apr-13 6:18
professionalkburman624-Apr-13 6:18 
QuestionFibonacci sequence Pin
Sottyoru22-Apr-13 6:47
Sottyoru22-Apr-13 6:47 
GeneralRe: Fibonacci sequence Pin
harold aptroot22-Apr-13 7:23
harold aptroot22-Apr-13 7:23 
GeneralRe: Fibonacci sequence Pin
Jasmine250122-Apr-13 7:25
Jasmine250122-Apr-13 7:25 
GeneralRe: Fibonacci sequence Pin
OriginalGriff22-Apr-13 8:51
mveOriginalGriff22-Apr-13 8:51 
GeneralRe: Fibonacci sequence Pin
PIEBALDconsult22-Apr-13 15:37
mvePIEBALDconsult22-Apr-13 15:37 
GeneralRe: Fibonacci sequence Pin
Manfred Rudolf Bihy22-Apr-13 20:18
professionalManfred Rudolf Bihy22-Apr-13 20:18 
GeneralRe: Fibonacci sequence Pin
OriginalGriff22-Apr-13 21:46
mveOriginalGriff22-Apr-13 21:46 
Factorials are the "normal" example given to students to teach them recursion:
!n == n * !(n - 1) where n > 1
So factorials are naturally limiting - whatever finite number you start with, there is a termination to the sequence. (And never mind that recursion is a poor way to implement it anyway)

Fibonacci numbers on the other hand are different:
Fn = F(n-1) + F(n-2) Where F0 = 0, and F1 = 1
So instead of decreasing towards a limit, Fibonacci numbers increase to towards infinity, with no limiting condition at all to terminate them. That makes them a poor candidate for recursion, because unless an artificial outside limit such as "n < 1000" is applied as well, the recursion continues indefinitely, and the stack is compromised.

Another very poor implementation!


Thinking on this before I posted, I realised that I was wrong: the only practical way to write Fibonacci sequences as recursive functions means providing the limit first, and then calculating all the values before it, in much the same way as a factorial would be - I was thinking of it in terms of calculating the sequence from the start, without providing a limit: the sensible way since it doesn't duplicate work!
As a result, I was wrong, the stack won't self destruct. Blush | :O

It's still a silly recursion example though! Laugh | :laugh:
The universe is composed of electrons, neutrons, protons and......morons. (ThePhantomUpvoter)

GeneralRe: Fibonacci sequence Pin
Manfred Rudolf Bihy22-Apr-13 22:08
professionalManfred Rudolf Bihy22-Apr-13 22:08 
AnswerRe: Fibonacci sequence Pin
PIEBALDconsult22-Apr-13 15:40
mvePIEBALDconsult22-Apr-13 15:40 
AnswerRe: Fibonacci sequence Pin
PIEBALDconsult22-Apr-13 16:02
mvePIEBALDconsult22-Apr-13 16:02 
AnswerRe: Fibonacci sequence Pin
Abhinav S22-Apr-13 18:01
Abhinav S22-Apr-13 18:01 
AnswerRe: Fibonacci sequence Pin
Pete O'Hanlon22-Apr-13 19:48
mvePete O'Hanlon22-Apr-13 19:48 
AnswerRe: Fibonacci sequence Pin
Kenneth Haugland22-Apr-13 22:00
mvaKenneth Haugland22-Apr-13 22:00 
AnswerRe: Fibonacci sequence Pin
Clifford Nelson24-Apr-13 15:49
Clifford Nelson24-Apr-13 15:49 
QuestionThrow NullReferenceException in SendKeys.Send() Pin
tikcireviva22-Apr-13 3:49
tikcireviva22-Apr-13 3:49 
AnswerRe: Throw NullReferenceException in SendKeys.Send() Pin
Eddy Vluggen22-Apr-13 4:56
professionalEddy Vluggen22-Apr-13 4:56 
AnswerRe: Throw NullReferenceException in SendKeys.Send() Pin
Alan N22-Apr-13 5:49
Alan N22-Apr-13 5:49 
QuestionDatabind won't work for Combobox and Checkbox Pin
yuifox22-Apr-13 3:08
yuifox22-Apr-13 3:08 
AnswerRe: Databind won't work for Combobox and Checkbox Pin
Eddy Vluggen22-Apr-13 4:58
professionalEddy Vluggen22-Apr-13 4:58 
GeneralRe: Databind won't work for Combobox and Checkbox Pin
yuifox22-Apr-13 11:46
yuifox22-Apr-13 11:46 
AnswerRe: Databind won't work for Combobox and Checkbox Pin
Eddy Vluggen23-Apr-13 10:35
professionalEddy Vluggen23-Apr-13 10:35 
QuestionManipulating taskbar right click applicatin menu Pin
Andreas X21-Apr-13 23:09
professionalAndreas X21-Apr-13 23:09 
AnswerRe: Manipulating taskbar right click applicatin menu Pin
Eddy Vluggen22-Apr-13 0:32
professionalEddy Vluggen22-Apr-13 0:32 
GeneralRe: Manipulating taskbar right click applicatin menu Pin
Andreas X22-Apr-13 1:31
professionalAndreas X22-Apr-13 1:31 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.