The number 1=2 in sum name

Code examples

0
0

ways to represent a number as sum of 1's and 2's

// The number of ways to represent a number with only 1s and 2s is 
// equal to (n+1)th fibonacci number 
public static int nthFibonacciNumber(int n) {
	int[] arr = new int[n+2];
  	arr[0] = 0;
  	arr[1] = 1;
  	for(int i = 2; i <= n; i++) {
    	arr[i] = arr[i - 1] + arr[i -2];
    }
  	return arr[n];
}

In other languages

This page is in other languages

Русский
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................
Балгарскі
..................................................................................................................
Íslensk
..................................................................................................................