Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Numerics;
- namespace Simple_Loops
- {
- class Simple_Loops
- {
- static void Main(string[] args)
- {
- BigInteger n0 = BigInteger.Parse(Console.ReadLine());
- BigInteger n1 = BigInteger.Parse(Console.ReadLine());
- BigInteger n2 = BigInteger.Parse(Console.ReadLine());
- BigInteger next = 0;
- int N = int.Parse(Console.ReadLine());
- for (int i = 0; i < N - 3; i++)
- {
- next = n0 + n1 + n2;
- n0 = n1;
- n1 = n2;
- n2 = next;
- }
- if (N == 1) Console.WriteLine(n0);
- else if (N == 2) Console.WriteLine(n1);
- else if (N == 3) Console.WriteLine(n2);
- else Console.WriteLine(next);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement