Write a subroutine that calulates the nth term of a fibonacci sequence (not using recursion). The nth term is the only input received from the calling function. The input is the exact value of the number and not the location.
1. (15 points) Write a subroutine that calulates the nth term of a fibonacci sequence (not using recursion). The nth term is the only input received from the calling function. The input is the exact value of the number and not the location.
2. (15 points) Write a subroutine that calulates the factiorial of an input. This input is recieved as a memory location that is stored as an interger. The program should store the answer back into a variable of the same type but not overwrite the original value. ie:
void main(){
int x = 5;
int y = factorial(x);
}
int factorial(int& x){
int answer;
… some code…
return answer;
}
joyce
0