# falling_factorial produces AttributeError

• Mathematica:

Table[FactorialPower[n, n - k - 1], {n, 0, 5}, {k, 0, n}]
{{1}, {1, 1/2}, {2, 1, 1/3}, {6, 3, 1, 1/4}, {24, 12, 4, 1, 1/5}}

• Maple:

ff := (n,k) -> n!/(n-k)!:
for n from 0 to 5 do seq(ff(n, n-k-1), k=0..n) od;
1
1, 1/2
2, 1, 1/3
6, 3, 1, 1/4
24, 12, 4, 1, 1/5

• Sage:

 for n in range(6): [falling_factorial(n, n-k-1) for k in (0..n)]
AttributeError: 'int' object has no attribute 'parent'

edit retag close merge delete

Sort by ยป oldest newest most voted

For some reason, falling_factorial is expecting Sage's integers (Integer), not Python's ones (int). So replace range(6) by (0..5) in your command and it will work:

sage: for n in (0..5): [falling_factorial(n, n-k-1) for k in (0..n)]
[1]
[1, 1/2]
[2, 1, 1/3]
[6, 3, 1, 1/4]
[24, 12, 4, 1, 1/5]
[120, 60, 20, 5, 1, 1/6]

more

Thanks Eric! Still it's a bug.

( 2015-06-28 18:08:29 +0200 )edit

Indeed! There should be conversion of int to Integer in the function falling_factorial.

( 2015-06-29 10:29:05 +0200 )edit

Can you open a ticket for that, then, since you seem to understand it? My guess is that will be pretty easy to fix.

( 2015-06-29 14:59:30 +0200 )edit

The bug is fixed in Sage 7.1.

( 2016-04-15 16:48:55 +0200 )edit

## Stats

Seen: 104 times

Last updated: Jun 28 '15