English
Source / code snippets

Binomialkoeffizienten to charge: "N over k"-Algorithmus (Pascal´sches Dreieck)

 

p.specht

Info: in the Pascal´schen Dreieck begins The Zeilenzählung (n) with 0. The shape one "Quadratischen Polynoms" (Potenz 2) is therefore in the 3. row of supra to find, the 2. Term (k=2) but in the 2. slot!
proc BinKoeff :parameters n&,k&

    case n&=0:return 0.0
    case k&=0:return 1.0
    case (2*k&)>n&:k&=n&-k&
    declare r!,z&:z&=n&-k&:r!=z&+1

    Whileloop k&,2,-1

        r!=r!*(&Loop+z&)
        case r!>10^200:return -1.0
        r!=r!/&Loop

    endwhile

    return r!

endproc

 
Computer: Gerät, daß es in Mikrosekunden erlaubt, 50.000 Fehler zu machen, zB 'daß' statt 'das'...
05/10/21  
 




p.specht

nCr-Algorithmus (appendix To supra):
--------------------
an effiziente Berechnung the Binomialkoeffizienten is into most scientific Taschenrechnern by the nCr-Algorithmus realized - otherwise would there with N=70 already Overflow given! nCr should "n Choose r" hot, The english Bezeichnung ours "N over k" or. "k from N".
fountain: Wikipedia
Window Title "Binomialkoeffizient gem. ´n Choose r´ = nCr-Algorithmus"
'https://de.wikipedia.org/wiki/Binomialkoeffizient#Algorithmus_zur_effizienten_Berechnung
Window Style 24:Cls:declare N&,k&
Repeat:print "\n n =",:input N&:print " k =",:input k&
print "\n Binom_nCr(n,k) = ";stature$("%g",Binom_nCr(N&,k&))

Until &Loop'= 0

proc Binom_nCr :parameters N&,k&

case k&=0:return 1:case N&<=0:return 0
var P!=1:case (2*k&)>N&:k&=N&-k&

whileloop k&'with nCr zurück only Ganzzahlen on:

    P!=P!*(N&-k&+&Loop)/&Loop

endwhile

return P!

endproc

 
XProfan 11
Computer: Gerät, daß es in Mikrosekunden erlaubt, 50.000 Fehler zu machen, zB 'daß' statt 'das'...
05/27/21  
 



Zum Quelltext


Topictitle, max. 100 characters.
 

Systemprofile:

no Systemprofil laid out. [anlegen]

XProfan:

 Posting  Font  Smilies  ▼ 

Please register circa a Posting To verfassen.
 

Topic-Options

1.819 Views

Untitledvor 0 min.
Erhard Wirth06/14/24
p.specht11/21/21
R.Schneider11/20/21
Uwe Lang11/20/21
More...

Themeninformationen

this Topic has 1 subscriber:

p.specht (2x)


Admins  |  AGB  |  Applications  |  Authors  |  Chat  |  Privacy Policy  |  Download  |  Entrance  |  Help  |  Merchantportal  |  Imprint  |  Mart  |  Interfaces  |  SDK  |  Services  |  Games  |  Search  |  Support

One proposition all XProfan, The there's!


My XProfan
Private Messages
Own Storage Forum
Topics-Remember-List
Own Posts
Own Topics
Clipboard
Log off
 Deutsch English Français Español Italia
Translations

Privacy Policy


we use Cookies only as Session-Cookies because of the technical necessity and with us there no Cookies of Drittanbietern.

If you here on our Website click or navigate, stimmst You ours registration of Information in our Cookies on XProfan.Net To.

further Information To our Cookies and moreover, How You The control above keep, find You in ours nachfolgenden Datenschutzerklärung.


all rightDatenschutzerklärung
i want none Cookie