-
-
Save unilecs/78e6bd8cfb827ba91dfc0ca04a23716e to your computer and use it in GitHub Desktop.
Задача 68: Две цифры
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
public class Program | |
{ | |
public static int GetCount(int n) | |
{ | |
int Max = 32; | |
if (n > Max) return -1; | |
int[] arr = new int[Max]; | |
arr[1] = 2; | |
arr[2] = 4; | |
for (int i = 3; i <= n; i++) | |
{ | |
arr[i] = arr[i - 1] + arr[i - 2]; | |
} | |
return arr[n]; | |
} | |
public static void Main() | |
{ | |
Console.WriteLine("UniLecs"); | |
Console.WriteLine(string.Format("Answer = {0}", GetCount(3))); // 6 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment