Autor Beitrag
Dodekaeder
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 41

WinXP,Win95
Delphi 5
BeitragVerfasst: Sa 25.02.06 12:34 
Hallo
Ich möchte ein Stochastikprogramm in Delphi5 schreiben.
Und dafür brauche ich den Binomialkoeffizienten, d.h. ich möchte
z.B. 5 nCr 3 =10 (sprich:5 über 3=10) berechnen.(auf meinem Taschenrechner ist das die nCr Taste)Weiss jemand wie man das programmieren kann???

(n über k)=n!/(k!*(n-k)!) =>Binomialkoeffizient
n und k sind Variblen

Und wenn nicht, weiss dan jemand einen Befehl für die Fakultät einer Zahl in Delphi5?
Miri
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 657


Delphi 3 Prof., Delphi 2005 PE
BeitragVerfasst: Sa 25.02.06 12:39 
ich glaub kaum, dass es dafür ne eigene funktion gibt...
aber wenn du doch die formel kennst und hier im forum mal nach Suche in der Entwickler-Ecke FAKULTÄT suchst, da findest du bestimmt einiges, um das selbst zu basteln :)
Dodekaeder Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 41

WinXP,Win95
Delphi 5
BeitragVerfasst: Sa 25.02.06 14:25 
Thx :idea:
hab einige vielversprechende lösungen gefunden :D
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Sa 25.02.06 14:26 
nCr wird von Delphi direkt nicht unterstützt, da man das aber über das Pascal'sche Dreieck machen kann, hab ich das Spaßeshalber (weil man das auch für Bezier-Kurven brauch, in Omorphia implementiert:

OMathGeneral.pas --> Funktionen Binomial und BinomialRow.

Ist dort auch recht gut ASM-Optimiert. Aus Wertebereichs-Gründen, ist das Teil aber auf die Zeilen 0 bis 16391 begrenzt (danach gibt's nen Overflow ^^)

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.