How to resolve the algorithm Stirling numbers of the first kind step by step in the PureBasic programming language
How to resolve the algorithm Stirling numbers of the first kind step by step in the PureBasic programming language
Table of Contents
Problem Statement
Stirling numbers of the first kind, or Stirling cycle numbers, count permutations according to their number of cycles (counting fixed points as cycles of length one). They may be defined directly to be the number of permutations of n elements with k disjoint cycles. Stirling numbers of the first kind express coefficients of polynomial expansions of falling or rising factorials. Depending on the application, Stirling numbers of the first kind may be "signed" or "unsigned". Signed Stirling numbers of the first kind arise when the polynomial expansion is expressed in terms of falling factorials; unsigned when expressed in terms of rising factorials. The only substantial difference is that, for signed Stirling numbers of the first kind, values of S1(n, k) are negative when n + k is odd. Stirling numbers of the first kind follow the simple identities:
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Stirling numbers of the first kind step by step in the PureBasic programming language
Source code in the purebasic programming language
EnableExplicit
#MAX=12
#LZ=10
#SP$=" "
Dim s1.i(#MAX,#MAX)
Define n.i,k.i,x.i,s$,esc$
s1(0,0)=1
esc$=#ESC$+"[8;24;170t" ; Enlarges the console window
For n=0 To #MAX
For k=1 To n
s1(n,k)=s1(n-1,k-1)-(n-1)*s1(n-1,k)
Next
Next
If OpenConsole()
Print(esc$)
PrintN(~"Signed Stirling numbers of the first kind\n")
Print(#SP$+"k")
For x=0 To #MAX : Print(#SP$+RSet(Str(x),#LZ)) : Next
PrintN(~"\n n"+LSet("-",13*12,"-"))
For n=0 To #MAX
Print(RSet(Str(n),3))
For k=0 To #MAX : Print(#SP$+RSet(Str(s1(n,k)),#LZ)) : Next
PrintN("")
Next
Input()
EndIf
You may also check:How to resolve the algorithm GUI/Maximum window dimensions step by step in the FBSL programming language
You may also check:How to resolve the algorithm Monads/Maybe monad step by step in the M2000 Interpreter programming language
You may also check:How to resolve the algorithm Arithmetic-geometric mean step by step in the AppleScript programming language
You may also check:How to resolve the algorithm Conditional structures step by step in the Ela programming language
You may also check:How to resolve the algorithm McNuggets problem step by step in the Pascal programming language