zoukankan      html  css  js  c++  java
  • 大数

    大数运算
     1 using System;
     2 using System.Numerics;
     3 
     4 namespace ConsoleApplication1
     5 {
     6     class Program
     7     {
     8         static void Main(string[] args)
     9         {
    10             BigInteger tmp = BigInteger.Zero;
    11             System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
    12             sw.Start();
    13             //tmp = Factorial(15100);
    14             ForResult(99999);
    15             sw.Stop();
    16             Console.WriteLine(tmp.ToString().Length.ToString()+"   "+sw.Elapsed.ToString());
    17 
    18         }
    19         
    20         /// <summary>
    21         /// 使用递归
    22         /// </summary>
    23         /// <param name="i"></param>
    24         /// <returns></returns>
    25         public static System.Numerics.BigInteger Factorial(BigInteger i)
    26         {
    27             if (i < 0)
    28             {
    29                 return BigInteger.Zero;
    30             }
    31             else if(0==i)
    32             {
    33                 return 1;
    34             }
    35             else
    36                 return Factorial(i - 1* i;
    37         }
    38 
    39         public static BigInteger ForResult(BigInteger i)
    40         {
    41             BigInteger tmp=1;
    42             do
    43             {
    44                 tmp *= i;
    45                 i--;
    46             }
    47             while (i > 0);
    48             return tmp;
    49         }
    50 
    51     }
    52 }
    53 
  • 相关阅读:
    javascript 将中文符号转换成英文符号
    js 函数定义的2种方式
    javascript 面向对象编程(工厂模式、构造函数模式、原型模式)
    10.2.0.4 to 10.2.0.5 Installation of Patch Set Release (Windows)
    流接口驱动程序的工作原理和开发步骤嵌入式
    android开发面试题
    ORACLE-014:oracle中查看DBLinkpassword
    Java相关知识(一)
    Android 中模仿 Twitter 实现 Toolbar Indicator
    使用excel进行数据挖掘(3)----类别检測
  • 原文地址:https://www.cnblogs.com/muyoushui/p/1716507.html
Copyright © 2011-2022 走看看