Ask Your Question
1

falling_factorial produces AttributeError

asked 2015-06-28 16:50:16 +0100

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

1 Answer

Sort by ยป oldest newest most voted
3

answered 2015-06-28 17:52:00 +0100

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 18:08:29 +0100 )edit

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

eric_g gravatar imageeric_g ( 2015-06-29 10:29:05 +0100 )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 14:59:30 +0100 )edit

The bug is fixed in Sage 7.1.

eric_g gravatar imageeric_g ( 2016-04-15 16:48:55 +0100 )edit

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 16:50:16 +0100

Seen: 242 times

Last updated: Jun 28 '15