Advertisement
milen8204

SimpleLoop

Apr 4th, 2014
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.94 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Numerics;
  6.  
  7. namespace ConsoleApplication2
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             BigInteger result = new BigInteger();
  14.            
  15.             int memberOne = int.Parse(Console.ReadLine());
  16.             int memberTwo = int.Parse(Console.ReadLine());
  17.             int memberThree = int.Parse(Console.ReadLine());
  18.             int memberAdd = int.Parse(Console.ReadLine());
  19.  
  20.             BigInteger first = memberOne;
  21.             BigInteger second = memberTwo;
  22.             BigInteger third = memberThree;
  23.  
  24.             for (int i = 4; i <= memberAdd; i++)
  25.             {
  26.                 result = first + second + third;
  27.                 first = second;
  28.                 second = third;
  29.                 third = result;
  30.             }
  31.  
  32.             Console.WriteLine(result);
  33.         }
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement