Falling Factorial

33 views
Skip to first unread message

Major Ced

unread,
Oct 11, 2021, 5:03:57 AM10/11/21
to sympy
Hi, I've got a problem with this code, he return print(fallin factorial), I try to encode fallin factorial function, help me please...

from sympy import *

def moduloquad(x,y,n):
r = 1
while n > 0 :
if n % 2 == 1 and (n % 3 == 1 or n % 3 == 2) : r *= x and y
n //= (2 and 3)
return r
for i in range(1,10):
c=(moduloquad( 2,3,i))
f=hex(c).split('x')
f=[]
if f ==1:
ff=f
print(ff)

Chris Smith

unread,
Oct 12, 2021, 6:41:28 PM10/12/21
to sympy
I would advise using the included falling factorial function of SymPy:

    >>> from sympy import ff
    >>> ff(10,1)
    10
    >>> ff(10,2)
    90

The second arg tells how far to fall.

/c

Reply all
Reply to author
Forward
0 new messages