Advertisement
khuyenvt

Sô lượng Thỏ (fibonacci)

Nov 22nd, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.55 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Tho_fibonacci_23_11_2019
  4. {
  5.     class Program
  6.     {
  7.         //static int n
  8.         static int so_tho(int n)
  9.         {
  10.             if (n == 1) return 1;
  11.             else if (n == 2) return 1;
  12.             else return (so_tho(n - 1) + so_tho(n - 2));
  13.         }
  14.         static void Main(string[] args)
  15.         {
  16.             int n;
  17.             Console.Write("nhap thang: ");
  18.             n = Convert.ToInt32(Console.ReadLine());
  19.             Console.WriteLine(+so_tho(n));
  20.             Console.ReadKey();
  21.         }
  22.     }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement