Esempio n. 1
0
def getNthPellNumber( n ):
    '''
    From:  http://oeis.org/A000129

    a( n ) = round( ( 1 + sqrt( 2 ) ) ^ n )
    '''
    return getNthLinearRecurrence( [ 1, 2 ], [ 0, 1 ], n )
Esempio n. 2
0
def getNthNonagonalHexagonalNumber( n ):
    # a = fmul( 3, sqrt( 7 ) )
    # b = fadd( 8, a )
    # c = fsub( 8, a )

    # sign = 1 #power( -1, n )
    # exponent = fsub( fmul( 4, n ), 4 )

    # print( str( fmul( c, sign ) ) + '  ' + str( power( b, exponent ) ) )

    # return floor( fprod( [ fdiv( 9, 112 ), fmul( c, sign ), power( b, exponent ) ] ) )

    return getNthLinearRecurrence( [ 1, -1, -4162056194, 4162056194, 1 ],
                                   [ 1, 325, 5330229625, 1353857339341, 22184715227362706161 ],
                                   real_int( n ) )
Esempio n. 3
0
def getNthPellNumber( n ):
    return getNthLinearRecurrence( [ 1, 2 ], [ 0, 1 ], n )
Esempio n. 4
0
def getNthHeptagonalSquareNumber( n ):
    index = getNthLinearRecurrence( [ 1, -1, 0, -1442, 1442, 0, 1 ],
                                    [ 1, 6, 49, 961, 8214, 70225, 1385329 ], real_int( n ) )

    return getNthPolygonalNumber( index, 7 )
Esempio n. 5
0
def getNthHeptagonalTriangularNumber( n ):
    return getNthLinearRecurrence( [ 1, -1, -103682, 103682, 1 ],
                                   [ 1, 55, 121771, 5720653, 12625478965 ], real_int( n ) )
Esempio n. 6
0
def getNthPentagonalSquareNumber( n ):
    return getNthLinearRecurrence( [ 1, -9603, 9603 ], [ 1, 9801, 94109401 ], real_int( n ) )
Esempio n. 7
0
def getNthPentagonalTriangularNumber( n ):
    return getNthLinearRecurrence( [ 1, -195, 195 ], [ 1, 210, 40755 ], real_int( n ) )