the else-statement of my if-loop doesn't work in a function calling itself

Hi, I've just started to learn C++ and I'm using the cplusplus.com-tutorial as well as this highly recommendable German website:
http://projects.eml.org/bcb/people/ralph/CPP-Uebungen-08/

I've created a function that calculates a fibonacci number by calling itself, however, the programme always returns 1 instead of 0 when I type in 0, so the else-statement of my if-loop doesn't work. Apart from that the programme does what I expected.

This is my programme:
#include <iostream>

long long fibonacci (long long a)
{

if (a>=3)
return (fibonacci(a-1)+fibonacci(a-2));

else if (1<=a<=2)
return (1);

else
return (0);

}

int main ()

{ long long b;
std::cout << "Geben Sie ein, die wievielte Fibonaccizahl Sie berechnen lassen wollen.\n";
std::cin>>b;
std::cout<<"Die "<<b<<"te Fibonaccizahl lautet "<<fibonacci(b)<<".\n";
return 0;
}


Where is my mistake?

Thanks for your help!
You can't do 1<=a<=2 or better, you can but it doesn't do what you think.
The correct way is 1<=a && a<=2
Topic archived. No new replies allowed.