Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class Program
- {
- static void Main(string[] args)
- {
- double num1 = double.Parse(Console.ReadLine());
- double num2 = double.Parse(Console.ReadLine());
- double num3 = double.Parse(Console.ReadLine());
- int N = int.Parse(Console.ReadLine());
- if (N == 1)
- {
- Console.WriteLine(num1);
- }
- if (N == 2)
- {
- Console.WriteLine(num2);
- }
- if (N == 3)
- {
- Console.WriteLine(num3);
- }
- double num4 = 0;
- if (N != 1 && N != 2 && N != 3)
- {
- while (N - 3 > 0)
- {
- num4 = num1 + num2 + num3;
- num1 = num2;
- num2 = num3;
- num3 = num4;
- N--;
- }
- Console.WriteLine(num4);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement