News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

fibonacci loop

Started by RITZY G, August 14, 2006, 04:39:16 PM

Previous topic - Next topic

RITZY G

plz hlp how do i write loop to calculatte fibonacci numbers

mnemonic

If you explain in detail where your problem is I am sure some people are willing to help.
But noone is going to write it for you.

Btw, I miss the "No Homework" announcement thread...
Be kind. Everyone you meet is fighting a hard battle.--Plato
-------
How To Ask Questions The Smart Way

RITZY G

not sure how to use this formula   f(n)=f(n-1)+f(n-2),   

RITZY G

i want calculate the first seven fibonacci numbers and save each value in tthe eax register

mnemonic

Quote from: RITZY G on August 14, 2006, 05:01:47 PM
not sure how to use this formula   f(n)=f(n-1)+f(n-2),   
That is just part of the formula.
You probably missed that per definition f(0)=0 and f(1)=1.

So if we want to calculate f(2) we do it as follows:
f(2)=f(2-1)+f(2-2)
what leads us to
f(2)=f(1)+f(0)
and since we know that f(0)=0 and f(1)=1 we have the solution
f(2)=1+0
f(2)=1


We may now go further to f(3) which breaks down to
f(3)=f(3-1)+f(3-2)
f(3)=f(2)+f(1)

since we now know that f(2)=1 and f(1)=1we have the solution
f(3)=1+1
f(3)=2


This may be done until infinity.
The trick is to remember the last two fibonacci numbers and use them in the next following step
Be kind. Everyone you meet is fighting a hard battle.--Plato
-------
How To Ask Questions The Smart Way

sluggy

Quote from: RITZY G on August 14, 2006, 05:16:14 PM
i want calculate the first seven fibonacci numbers and save each value in tthe eax register
Ritzy, just a reminder that we encourage people to do their own homework. Raymond has given you the formula, now you have to write some code before you get more help, the members here will not write it for you.


Boucly

It isn't my homework, but I did it anyway.

Should I post what I've got or should I leave it for a later time, because I am not sure if it is right but I don't want to encourage people to post homeworks. And ... um ... RITZY G if you weren't really posting homework, sorry.

Boucly

Tedd

Boucly - no, don't post it.
We will happily help, there is even no problem helping with homework. But we will not DO the homework.
If Ritzy G can show that even a little attempt has been made, then we can help point that in the right direction, but so far this post is only a request for someone to do Ritzy's homework.

Ritzy:
Honestly, I don't care if it is or isn't homework. But if it is, then we're not going to do it for you. And if isn't, then the only reason to be doing it would be for learning, and you will learn nothing if someone else does it, so we're not going to do it for you.
Post what have done so far, and we can help from there. If you have a problem understanding how to use the formula/print numbers/program, then you can ask specific questions about that and we help you there too.
No snowflake in an avalanche feels responsible.