0
How to print Fibonacci series upto -nth term
12 ответов
+ 2
Thanks, SoloProg!
My question was for a negative number ex: if input is equal 8 then fibbonaci series should be printed till 8 not more than 8 .
Hope you understood
Could you please check provide a solution if possible
+ 2
Ashok Kumar V , Hope this helps
Fibonacci Series using Recursion
Positive and negative numbers
https://www.sololearn.com/compiler-playground/cMeUZON38E5o
+ 1
Ashok Kumar V , Hope this helps
Fibonacci Series using Recursion
int fib(int n)
{
if (n <= 1) return n;
return fib(n-1) + fib(n-2);
}
https://www.sololearn.com/compiler-playground/cMBrriF5zsU8
+ 1
You want to print only negative number? like if you input the number 8 then fibonacci series print -1 to -8 like this.
+ 1
My input is negative number
+ 1
Ashok Kumar V you can't take input directly in negative number.
+ 1
Sakshi see my above code
+ 1
In while condition after that you write c = a - b; then it subtract the value.
+ 1
Your main question is how to input the negative value then it's not possible, you can store the value in positive or negative way instead of input.
+ 1
I hope it's clear to you
+ 1
Okay thanks
+ 1
Thanks! Soloprog