找到的数字不是用X整除的杨辉三角的第100行号行号、数字、不是、杨辉三角

2023-09-11 07:12:54 作者:浪味小仙女吖

我需要找出数字不属于整除的帕斯卡三角的第100行中的数x的数量。

I need to find out the number of digits which are not divisible by a number x in the 100th row of Pascal's triangle.

余施加,以便找到该算法是:因为帕斯卡三角是11从上第二行的权力,第n行可以通过11中找到^(N-1),并且可以很容易地进行检查的量的数字是不能整除×。

The algorithm I applied in order to find this is: since Pascal's triangle is powers of 11 from the second row on, the nth row can be found by 11^(n-1) and can easily be checked for which digits are not divisible by x.

我要如何找到这一点对于较大的数字时n等于99或100?是否有可用于查找此任何其他算法

How do I find this out for large numbers when n is equal to 99 or 100? Is there any other algorithm that can be applied to find this?

推荐答案

您可以直接计算使用阶乘(N杨辉三角的价值!/(N-K + 1)!(K-1)!第n行,第k值)。您可以使用K = 1开始,增量计算二项式系数和N / 2个步骤,你可以找到一些没有用x整除。

You can directly calculate values of pascal's triangle using factorials (n!/(n-k+1)!(k-1)! nth row, kth value). You can start with k=1, incrementally calculate binomial coefficient and in n/2 steps you can find the number not divisible by x.

选择(N,K + 1)=选择(N,K)*(N-K + 1)/ k其中选择(N,K)=(N!/(N-K + 1)!(K -1)!

choose(n,k+1) = choose(n,k)*(n-k+1)/k where choose(n,k) = (n!/(n-k+1)!(k-1)!