## Informatica Interview Question

iOS Developers**Team:**interviews

**Country:**United States

**Interview Type:**Written Test

C++

```
void printFiboCount(int n)
{
if(n==0)
{
cout<<"1 0"<<endl;
}else if(n==1)
{
cout<<"0 1"<<endl;
}else
{
int n2Ones = 0; // f(0)
int n2Zeros = 1; // f(0)
int n1Ones = 1; // f(1)
int n1Zeros = 0; // f(1)
for (int i = 2; i<n;i++)
{
int newNOnes = n2Ones + n1Ones;
int newNZeros = n2Zeros + n1Zeros;
n2Zeros = n1Zeros;
n2Ones = n1Ones;
n1Zeros = newNZeros;
n1Ones = newNOnes;
}
cout<<(n2Zeros + n1Zeros)<<" "<<(n2Ones + n1Ones)<<endl;
}
}
```

Number of 1's for N is Nth fibonacci term

- Anonymous December 27, 2013Number of 0's for N is (N-1)th fibonacci term