RosettaCodeData/Task/Faulhabers-triangle/Factor/faulhabers-triangle.factor
2023-07-01 13:44:08 -04:00

8 lines
261 B
Factor

USING: kernel math math.combinatorics math.extras math.functions
math.ranges prettyprint sequences ;
: faulhaber ( p -- seq )
1 + dup recip swap dup 0 (a,b]
[ [ nCk ] [ -1 swap ^ ] [ bernoulli ] tri * * * ] 2with map ;
10 [ faulhaber . ] each-integer