コード例 #1
0
        private long GetFirstTriangleNumberWithAtLeastNDivisor(int requiredNumberOfDivisors)
        {
            int n = 1;
            var nthTriangleNumber = TriangleNumberHelper.GetNthTriangleNumber(n);

            while (DivisorHelper.GetNumberOfDivisors(nthTriangleNumber) < requiredNumberOfDivisors)
            {
                n++;
                nthTriangleNumber = TriangleNumberHelper.GetNthTriangleNumber(n);
            }
            return(nthTriangleNumber);
        }
コード例 #2
0
 public void GetNthTriangleNumber_ReturnsCorrectResult(int n, long nthTriangleNumber)
 {
     TriangleNumberHelper.GetNthTriangleNumber(n).Should().Be(nthTriangleNumber);
 }