in this type of math you need to get answers for ncr equations which in involve finding out the answer to say 15! (15 * 14 * 13.... and so on)
this code here will do fine it will get my ncr math me like it will provide the answer to 3c2 which is 10 using the n! / (R1 * (n-r)!) formula but when ever i use something like 15c15 for example or anything for a r variable the "i" variable in my code which essentially represents n! will produce a overflow error. as you can see my method take 1 * 1 at first which is fine then 1* 2 *3* 4 and so on till it hits whatever value i put in the text box for it x reaches 13 and crashes with said error. now assuming i have the variables declared right and i do have code to produce the result in another text box i just didn't include it here.
so my question here is why can say a calculator like say speed crunch can handle huge numbers like that and this code can't?
For x = 1 To Val(power.Text) i = i * Val(x) Next For z = 0 To Val(power.Text) nr = Val(power.Text) - Val(z) ii = 1 ii2 = 1 For w = 0 To Val(z) ii = ii * Val(w) If ii = 0 Then ii = 1 End If Next For v = 0 To Val(nr) ii2 = ii2 * Val(v) If ii2 = 0 Then ii2 = 1 End If Next p = Val(i) / (Val(ii) * Val(ii2)) For x = 1 To Val(z) u = Val(power.Text) - x d = x Next next

New Topic/Question
Reply




MultiQuote





|