
1 斯特林数
在组合数学,斯特林数可指两类数,第一类斯特林数和第二类斯特林数,都是由18世纪数学家James Stirling提出的。它们自18世纪以来一直吸引许多数学家的兴趣,如欧拉、柯西、西尔沃斯特和凯莱等。后来哥本哈根(Copenhagen)大学的尼尔森(Niels Nielsen,1865-1931)提出了"Stirlingschen Zahlen erster Art" [第一类斯特林数]和"Stirlingschen Zahlen zweiter Art" [第二类斯特林数],首次把这两类数冠以「斯特林数」之名 。
更多知识课阅读百度百科:
百度百科《斯特林数》 https://baike.baidu.com/item/%E6%96%AF%E7%89%B9%E6%9E%97%E6%95%B0/4938529?fr=aladdin
https://baike.baidu.com/item/%E6%96%AF%E7%89%B9%E6%9E%97%E6%95%B0/4938529?fr=aladdin
2 计算结果

(一类斯特林数)源程序:
3 源代码
using System;
namespace Legalsoft.Truffer.Algorithm
 {
     public static partial class Number_Sequence
     {
         private static long Factorial(int n)
         {
             if (n == 0)
             {
                 return 1;
             }
             if (n < 0)
             {
                 return -1;
             }
             long res = 1;
             for (int i = 2; i < (n + 1); i++)
             {
                 res *= i;
             }
             return res;
         }
        private static int Combination(int n, int r)
         {
             if (r > n)
             {
                 return -1;
             }
             if (n == r)
             {
                 return 1;
             }
             if (r == 0)
             {
                 return 1;
             }
             return Combination(n - 1, r - 1) + Combination(n - 1, r);
         }
        public static long Stirling_Number(int r, int n)
         {
             if (n > r)
             {
                 return -1;
             }
             if (n == 0)
             {
                 return 0;
             }
             if (r == n)
             {
                 return 1;
             }
             if (n == 1)
             {
                 return Factorial(r - 1);
             }
             if (r - n == 1)
             {
                 return Combination(r, 2);
             }
             else
             {
                 return Stirling_Number(r - 1, n - 1) + (r - 1) * Stirling_Number(r - 1, n);
             }
         }
     }
 }
  
————————————————————
POWER BY TRUFFER.CN
4 代码格式
using System;
namespace Legalsoft.Truffer.Algorithm
{
    public static partial class Number_Sequence
    {
        private static long Factorial(int n)
        {
            if (n == 0)
            {
                return 1;
            }
            if (n < 0)
            {
                return -1;
            }
            long res = 1;
            for (int i = 2; i < (n + 1); i++)
            {
                res *= i;
            }
            return res;
        }
        private static int Combination(int n, int r)
        {
            if (r > n)
            {
                return -1;
            }
            if (n == r)
            {
                return 1;
            }
            if (r == 0)
            {
                return 1;
            }
            return Combination(n - 1, r - 1) + Combination(n - 1, r);
        }
        public static long Stirling_Number(int r, int n)
        {
            if (n > r)
            {
                return -1;
            }
            if (n == 0)
            {
                return 0;
            }
            if (r == n)
            {
                return 1;
            }
            if (n == 1)
            {
                return Factorial(r - 1);
            }
            if (r - n == 1)
            {
                return Combination(r, 2);
            }
            else
            {
                return Stirling_Number(r - 1, n - 1) + (r - 1) * Stirling_Number(r - 1, n);
            }
        }
    }
}
















![贰[2],Xamarin生成APK](https://img-blog.csdnimg.cn/direct/266a6e2cc0e048fd9ff6b323cb9a028f.png)


