answersLogoWhite

0


Best Answer

The process requires an understanding of the problem, understanding the tool, then the implementation in edit/test cycles.

For example, you would want to understand the task first. Are you required to "write a Fibonacci number sequence" as a series of Fibonacci numbers in a range from A to B (e.g. 0, 1, 1, 2, 3, 5, 8), or are you required to create a tool that can create fib(N) for any argument N? What are the value constraints for N? Is the implementation of fib() required to support any number of N, including very large numbers or even infinity?

The next step would be the selection of a suitable tool and algorithm. For example, one would want to use an assembly language based on its theoretically superior processing speed. (One might want to chose a higher-level programming language, for example in order to support portability of code to other processors.)

The selection of the algorithm is also important. The mathematical definition of the Fibonacci number can be written as fib(N) = fib(N-1) + fib(N-2). These instructions naturally suggest a recursive algorithm, however, recursive algorithms are not suitable for very large arguments due to the resulting recursion depth. Since every recursive algorithm has an iterative equivalent, an iterative approach might be a better solution.

Neither recursive nor iterative "brute force" implementations are suitable for very large arguments N, as the processing time is a function of N itself. Therefore, depending on the exact understanding of the problem, a different algorithm may need inventing.

Once the problem and its preconditions are understood, the algorithm and programming language is chosen, the solution is implemented in edit/test cycles. This process is the same whether an assembly or a higher-level language is chosen.

The exact sequence of the instructions in the chosen language depends on the choice of language, algorithm and the exact understanding of the problem. For assembly languages, the exact sequence of instructions further depend on the choice of one specific assembly language, given that each processor family has its own assembly language.

User Avatar

Wiki User

10y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do you write a Fibonacci number sequence as a function in assembly language?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

Write a program to print the Fibonacci series in php upto input value using recursive function?

The Fibonacci sequence uses recursion to derive answers. It is defined as: F0 = 0 F1 = 1 Fn = F(n - 1) + F(n -2) To have this sequence printed by a php script use the following: function fibonacci($n) { if($n 1) return 1; //F1 else return fibonacci($n - 1) + fibonacci($n - 2); //Fn } This recursive function will print out the Fibonacci number for the integer n. To make it print out all the numbers in a particular set add this to your script. for($i = 0; $i < 15; $i++) { echo fibonacci($i) . "<br />"; } So your final result would look like. <?php function fibonacci($n) { if($n 1) return 1; else return fibonacci($n - 1) + fibonacci($n - 2); } for($i = 0; $i < 15; $i++) { echo fibonacci($i) . "<br />"; } ?>


Is Assembly-language programs are written using binary codes?

Assembly language allows the developer to have almost total control over what the sequence of instructions will be when a program executes. A compiler tries to translate a high level language such as C++ into a series of instructions, but a good assembly language programmer may be able to optimize the sequence when a compiler cannot. Primarily assembly language is used for speed and optimal machine code.


How do you check whether a given number n is a Fibonacci number or not?

In a Fibonacci sequence, sum of two successive terms gives the third term.... here is the Fibonacci sequence: 0,1,1,2,3,5,8,13,21,34,55,89,144........ General formula to generate a Fibonacci sequence is """Fn= Fn-1 + Fn-2""" To check whether a number is Fibonacci or not follow the following steps: 1) Get the number as input from user. 2) Fix the first two numbers of sequence as 0 and 1. 3) put a sentinel loop with upper limit being the input number. 4)in the body of loop generate the next number in sequence in each iteration and continue swapping the values as follows: a=0 b=1 next=a+b while (next< input) a=b b=next next=a+b wend 5) lastly when program exits the loop compare the last number of sequence with the input number if they are equal then number is Fibonacci otherwise not. otherwise the last term of sequence will be less than the input number.


Where function execution ends in c language?

In C, function execution ends with the return statement or when execution encounters the last brace, }, that matches the opening brace, {. If the function is typed, such as int myfunc(), then encountering the last brace is considered an error, because that sequence returns no value.


Describe the sequence of events that takes place when an interrupt is raised?

Interrupt Handling 1. Hardware stacks program counter, etc. 2. Hardware loads new program counter from interrupt vector. 3. Assembly language procedure saves registers. 4. Assembly language procedure sets up new stack. 5. C interrupt service runs (typically reads and buffers input). 6. Scheduler decides which process is to run next. 7. C procedure returns to the assembly code. 8. Assembly language procedure starts up new current process.