Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
22
Task/Lah-numbers/Sidef/lah-numbers.sidef
Normal file
22
Task/Lah-numbers/Sidef/lah-numbers.sidef
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
func lah(n, k) {
|
||||
stirling3(n, k)
|
||||
#binomial(n-1, k-1) * n!/k! # alternative formula
|
||||
}
|
||||
|
||||
const r = (0..12)
|
||||
|
||||
var triangle = r.map {|n| 0..n -> map {|k| lah(n, k) } }
|
||||
var widths = r.map {|n| r.map {|k| (triangle[k][n] \\ 0).len }.max }
|
||||
|
||||
say ('n\k ', r.map {|n| "%*s" % (widths[n], n) }.join(' '))
|
||||
|
||||
r.each {|n|
|
||||
var str = ('%-3s ' % n)
|
||||
str += triangle[n].map_kv {|k,v| "%*s" % (widths[k], v) }.join(' ')
|
||||
say str
|
||||
}
|
||||
|
||||
with (100) {|n|
|
||||
say "\nMaximum value from the L(#{n}, *) row:"
|
||||
say { lah(n, _) }.map(^n).max
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue