Ask Your Question
0

falling_factorial produces AttributeError

asked 2015-06-28 09:50:16 -0600

Peter Luschny gravatar image
  • 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 flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
2

answered 2015-06-28 10:52:00 -0600

eric_g gravatar image

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]
edit flag offensive delete link more

Comments

Thanks Eric! Still it's a bug.

Peter Luschny gravatar imagePeter Luschny ( 2015-06-28 11:08:29 -0600 )edit

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

eric_g gravatar imageeric_g ( 2015-06-29 03:29:05 -0600 )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.

kcrisman gravatar imagekcrisman ( 2015-06-29 07:59:30 -0600 )edit
0

answered 2016-04-15 09:48:55 -0600

eric_g gravatar image

The bug is fixed in Sage 7.1.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2015-06-28 09:50:16 -0600

Seen: 65 times

Last updated: Jun 28 '15