Advertisement
JeffGrigg

Factorial with long in C#

Jun 28th, 2018
506
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 8.14 KB | None | 0 0
  1. //Rextester.Program.Main is the entry point for your code. Don't change it.
  2. //Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5
  3.  
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Text.RegularExpressions;
  8.  
  9. namespace Rextester
  10. {
  11.     public class Program
  12.     {
  13.         public static void Main(string[] args)
  14.         {
  15.             //Your code goes here
  16.            
  17. double fact = 1;
  18. int i = 0;
  19. do
  20. {
  21. i++;
  22. fact *= i;
  23. Console.WriteLine(i.ToString() + " = " + fact.ToString("#"));
  24. }
  25. while (i < 100);
  26.            
  27.         }
  28.     }
  29. }
  30.  
  31.  
  32. // Output from http://rextester.com/
  33.  
  34. /*
  35.  
  36. 1 = 1
  37. 2 = 2
  38. 3 = 6
  39. 4 = 24
  40. 5 = 120
  41. 6 = 720
  42. 7 = 5040
  43. 8 = 40320
  44. 9 = 362880
  45. 10 = 3628800
  46. 11 = 39916800
  47. 12 = 479001600
  48. 13 = 6227020800
  49. 14 = 87178291200
  50. 15 = 1307674368000
  51. 16 = 20922789888000
  52. 17 = 355687428096000
  53. 18 = 6402373705728000
  54. 19 = 121645100408832000
  55. 20 = 2432902008176640000
  56. 21 = 51090942171709400000
  57. 22 = 1124000727777610000000
  58. 23 = 25852016738885000000000
  59. 24 = 620448401733239000000000
  60. 25 = 15511210043331000000000000
  61. 26 = 403291461126606000000000000
  62. 27 = 10888869450418400000000000000
  63. 28 = 304888344611714000000000000000
  64. 29 = 8841761993739700000000000000000
  65. 30 = 265252859812191000000000000000000
  66. 31 = 8222838654177920000000000000000000
  67. 32 = 263130836933694000000000000000000000
  68. 33 = 8683317618811890000000000000000000000
  69. 34 = 295232799039604000000000000000000000000
  70. 35 = 10333147966386100000000000000000000000000
  71. 36 = 371993326789901000000000000000000000000000
  72. 37 = 13763753091226300000000000000000000000000000
  73. 38 = 523022617466601000000000000000000000000000000
  74. 39 = 20397882081197400000000000000000000000000000000
  75. 40 = 815915283247898000000000000000000000000000000000
  76. 41 = 33452526613163800000000000000000000000000000000000
  77. 42 = 1405006117752880000000000000000000000000000000000000
  78. 43 = 60415263063373800000000000000000000000000000000000000
  79. 44 = 2658271574788450000000000000000000000000000000000000000
  80. 45 = 119622220865480000000000000000000000000000000000000000000
  81. 46 = 5502622159812090000000000000000000000000000000000000000000
  82. 47 = 258623241511168000000000000000000000000000000000000000000000
  83. 48 = 12413915592536100000000000000000000000000000000000000000000000
  84. 49 = 608281864034268000000000000000000000000000000000000000000000000
  85. 50 = 30414093201713400000000000000000000000000000000000000000000000000
  86. 51 = 1551118753287380000000000000000000000000000000000000000000000000000
  87. 52 = 80658175170943900000000000000000000000000000000000000000000000000000
  88. 53 = 4274883284060030000000000000000000000000000000000000000000000000000000
  89. 54 = 230843697339241000000000000000000000000000000000000000000000000000000000
  90. 55 = 12696403353658300000000000000000000000000000000000000000000000000000000000
  91. 56 = 710998587804863000000000000000000000000000000000000000000000000000000000000
  92. 57 = 40526919504877200000000000000000000000000000000000000000000000000000000000000
  93. 58 = 2350561331282880000000000000000000000000000000000000000000000000000000000000000
  94. 59 = 138683118545690000000000000000000000000000000000000000000000000000000000000000000
  95. 60 = 8320987112741390000000000000000000000000000000000000000000000000000000000000000000
  96. 61 = 507580213877225000000000000000000000000000000000000000000000000000000000000000000000
  97. 62 = 31469973260387900000000000000000000000000000000000000000000000000000000000000000000000
  98. 63 = 1982608315404440000000000000000000000000000000000000000000000000000000000000000000000000
  99. 64 = 126886932185884000000000000000000000000000000000000000000000000000000000000000000000000000
  100. 65 = 8247650592082470000000000000000000000000000000000000000000000000000000000000000000000000000
  101. 66 = 544344939077443000000000000000000000000000000000000000000000000000000000000000000000000000000
  102. 67 = 36471110918188700000000000000000000000000000000000000000000000000000000000000000000000000000000
  103. 68 = 2480035542436830000000000000000000000000000000000000000000000000000000000000000000000000000000000
  104. 69 = 171122452428141000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  105. 70 = 11978571669969900000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  106. 71 = 850478588567862000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  107. 72 = 61234458376886100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  108. 73 = 4470115461512680000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  109. 74 = 330788544151939000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  110. 75 = 24809140811395400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  111. 76 = 1885494701666050000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  112. 77 = 145183092028286000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  113. 78 = 11324281178206300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  114. 79 = 894618213078297000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  115. 80 = 71569457046263800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  116. 81 = 5797126020747370000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  117. 82 = 475364333701284000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  118. 83 = 39455239697206600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  119. 84 = 3314240134565350000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  120. 85 = 281710411438055000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  121. 86 = 24227095383672700000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  122. 87 = 2107757298379530000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  123. 88 = 185482642257398000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  124. 89 = 16507955160908500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  125. 90 = 1485715964481760000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  126. 91 = 135200152767840000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  127. 92 = 12438414054641300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  128. 93 = 1156772507081640000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  129. 94 = 108736615665674000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  130. 95 = 10329978488239100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  131. 96 = 991677934870949000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  132. 97 = 96192759682482100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  133. 98 = 9426890448883240000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  134. 99 = 933262154439441000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  135. 100 = 93326215443944100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
  136.  
  137. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement