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 SoftUni_Homework_1_3
- {
- class Program
- {
- static void Main(string[] args)
- {
- uint[] numbers = new uint[] { 100, 171, 250 }; // Numbers of factorials to be printed
- uint counter = 1; // Variable used for iteration
- /* BigInteger class (.NET framework 4.5) https://msdn.microsoft.com/en-us/library/system.numerics.biginteger(v=vs.110).aspx */
- BigInteger factorial = new BigInteger(1);
- while (counter <= numbers[2])
- {
- factorial = BigInteger.Multiply(factorial, counter ); // Calculate factorial
- if (numbers.Contains(counter))
- {
- Console.WriteLine("!"+counter.ToString() + "=" + factorial.ToString() + '\n'); // Output the value if it's in the list
- }
- counter++;
- }
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement