ProgrammingVery hardCompetitive coding (CP)

How many tilings does a 2 by 5 board have with 2 by 1 dominoes? Compute with this recursive program.

How many tilings does a 2 by 5 board have with 2 by 1 dominoes? Compute with this recursive program.
#include <stdio.h>
int f(int n) {
    if (n <= 1) return 1;
    return f(n - 1) + f(n - 2);
}
int main(void) {
    printf("%d", f(5));
}
  1. A. 8
  2. B. 5
  3. C. 13
  4. D. 7

Correct answer: A. 8

A 2 by n board has F(n+1) domino tilings, and the recursion gives f(5) = 8.

More C Programming questions

Exams that ask this topic