Advertisement
Guest User

SoftUni_Homework_1_3

a guest
Aug 17th, 2015
301
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Numerics;
  7.  
  8.  
  9. namespace SoftUni_Homework_1_3
  10. {
  11. class Program
  12. {
  13. static void Main(string[] args)
  14. {
  15. uint[] numbers = new uint[] { 100, 171, 250 }; // Numbers of factorials to be printed
  16. uint counter = 1; // Variable used for iteration
  17. /* BigInteger class (.NET framework 4.5) https://msdn.microsoft.com/en-us/library/system.numerics.biginteger(v=vs.110).aspx */
  18. BigInteger factorial = new BigInteger(1);
  19. while (counter <= numbers[2])
  20. {
  21. factorial = BigInteger.Multiply(factorial, counter ); // Calculate factorial
  22. if (numbers.Contains(counter))
  23. {
  24. Console.WriteLine("!"+counter.ToString() + "=" + factorial.ToString() + '\n'); // Output the value if it's in the list
  25. }
  26. counter++;
  27. }
  28. Console.ReadKey();
  29. }
  30. }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement