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 _02.Simple_Loops
- {
- class SimpleLoops
- {
- static void Main(string[] args)
- {
- BigInteger first = BigInteger.Parse(Console.ReadLine());
- BigInteger second = BigInteger.Parse(Console.ReadLine());
- BigInteger third = BigInteger.Parse(Console.ReadLine());
- int numberOfElement = int.Parse(Console.ReadLine());
- if (numberOfElement == 1)
- {
- Console.WriteLine(first);
- }
- else if (numberOfElement == 2)
- {
- Console.WriteLine(second);
- }
- else if (numberOfElement == 3)
- {
- Console.WriteLine(third);
- }
- else
- {
- for (int i = 4; i <= numberOfElement; i++)
- {
- BigInteger tribonacciNumber = first + second + third;
- first = second;
- second = third;
- third = tribonacciNumber;
- }
- Console.WriteLine(third);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement