My program prints out Fibonacci_number(0,1,1,2,3,5). The program is ok.
My problem:I want to take a number from Fibonacci_number(0,1,1,2,3,5)
and multiply whit 10. ex: I want to take 3 and multiply with 10.
I tried to write another function and call a Fibonacci_number from
fib(int k)and then multiply it whit 10.
How can I call an exact Fibonacci_number.

``````int fib(int k)
{

int my_nbr=0;
int f;

int  nbr1 = 0;
int  nbr2 = 1;
printf("0,1");

for (f = 2; f < k; ++f)
{
printf(",%d", nbr1 + nbr2);

my_nbr= nbr2;
nbr2 = nbr2 + nbr1;
nbr1 = my_nbr;

}
printf("\n");

}

int main(void)
{
fib(6);

return 0;
}``````
2
Contributors
1
2
Views
12 Years
Discussion Span
Last Post by Dave Sinkula

I am having a difficult time understanding what it is you are asking. But what I think you want is a function that returns the fibonacci number of the value passed to the function, such that
fib(0) = 0
fib(1) = 1
fib(2) = 1
fib(3) = 2
fib(4) = 3
fib(5) = 5
fib(6) = 8So instead of printing the values in the loop, you would want your function to return a value. Hint.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.