 HP-300s cannot do nCr for many allowable values - Printable Version +- HP Forums (https://archived.hpcalc.org/museumforum) +-- Forum: HP Museum Forums (https://archived.hpcalc.org/museumforum/forum-1.html) +--- Forum: Old HP Forum Archives (https://archived.hpcalc.org/museumforum/forum-2.html) +--- Thread: HP-300s cannot do nCr for many allowable values (/thread-173300.html) HP-300s cannot do nCr for many allowable values - DeboT - 10-14-2010 The HP-300s cannot do nCr for many allowable valuesE.g. 200C55 = 7.718340811E49 gives an error on the 300s. Similarly on the Casio fx-85GT plus, and Sharp EL-W506.It seems to me that these new line of calculators all share the same code.Fortunately for the EL-W506, I have a workaround as it has the SUM capability:nCr = 10^(SUM(x=A downto A-B+1, logX) - SUM(X=1 to B, logX)),or as per 506 display: ``` / A-B+1 B \ ( SUM (logX, -1) - SUM (logX) ) \ X=A X=1 / 10 ``` where A = n and B = the lesser of r or n-r.This can then be stored in a formula memory for future use.This formula was adapted from Eamonn's "Updated HP-25 C(n,r) program", message 17 in this thread.Unfortunately HP seems to have only purchased a sub-set of these functions for the 300s and does not contain the SUM function.. Edited to fix a small typo Edited: 14 Oct 2010, 10:07 a.m. after one or more responses were posted Re: HP-300s cannot do nCr for many allowable values - Crawl - 10-14-2010 Quote: Fortunately for the EL-W506, I have a workaround as it has the SUM capability: Huh? If you're talking about this calculator, I'm pretty sure it does not have the sum capability. Maybe this one does, though. But the 506w does use Simpson's rule for evaluating integrals, so it can be manipulated into performing sums: The funny (b-a)/2 argument in the integrals is the third argument you give the integrator, the one that indicates how many applications of Simpson's rule are to be used. Obviously that's a pretty complicated formula, but if b-a is large enough it can save some time as compared to entering the sums manually. Re: HP-300s cannot do nCr for many allowable values - DeboT - 10-14-2010 Hi Crawl, I'm talking about this calculator, note that the W is before the 506. A small difference in model no., but quite a different calculator :)May be there's a difference in model no.'s for US and EU release, the EL-W516B being the US equivalent of EL-W506? Re: HP-300s cannot do nCr for many allowable values - Gene Wright - 10-14-2010 Define "allowable" values. If the nCr or nPr functions are done using the x! function, allowable values will not include the 200. Re: HP-300s cannot do nCr for many allowable values - DeboT - 10-14-2010 Hi Gene, For "allowable" values I mean what the manual states: 0 n-r) r = n-r; // get the smaller of r and n-r result = n-c+1; f = result+1; // the next factor for (d = 2 to r) { result = result * f; result = result / d; // do the * and / in the right order! ++f; } return result; } ``` The first 2 lines in the "for" loop could be combined into result = result * f / d, but I split them apart to stress that the multiply must come first. Dave Re: HP-300s cannot do nCr for many allowable values - DeboT - 10-15-2010 Hi Dave,Yes, I have often implenemted similar product iterative routines in BASIC on old Sharp programmables (PC-1251 etc.). However the EL-W506 does not have programming nor does it have a PRODUCT function, the only iterative function is the SUM function (and integrate function as pointed out by Crawl), thus I had to devise a way to use that. The accuracy of the results have been satisfactory so far. e.g. ```Inputs EL-W506 using Formula Wolfram Alpha 90C7 7471735560 7471375560 101C6 1267339920 1267339920 70C8 9440350920 9440350920 425C23 5.987299533E37 5.9872995328217166490998168... × 10^37 200C55 7.718340811E49 7.7183408114309579595976889... × 10^49 335C167 3.044358792E99 3.04435879314697921045998279... × 10^99 ``` Unfortunately I wanted to use combinatorials in another SUM function, but as I cannot use a SUM within a SUM, and I can't find a way of using a stored formula within another formula (on the EL-W506), so I'm back to programmable calculators :(. Edit: Dave Hayden said Quote: So after each division, you've computed a different nCr which is guaranteed to be an integer. The Sum function of course will always use the integer of any of its arguments (e.g. Sum X, X=1 to 5.8 will still produce 15), this may one the reasons for the reasonably good accuracy demonstrated above. Edited: 2 Nov 2010, 1:07 p.m. OT did you use a wacom - bill platt - 10-15-2010 did you use a wacom tablet for that writing of yours? [MORE] HP-300s cannot do nCr for many allowable values - Karl Schneider - 10-16-2010 Quote: The HP-300s cannot do nCr for many allowable values E.g. 200C55 = 7.718340811E49 gives an error on the 300s. Similarly on the Casio fx-85GT plus, and Sharp EL-W506. ... For "allowable" values I mean what the manual states: 0y 61. y^x 62. GTO 00 Re: HP-300s cannot do nCr for many allowable values - Marcus von Cube, Germany - 10-30-2010 A better readable version of the above: Here is the 12c Version for nCr. ```Store n in R1 and r in R2 Registers used: R3 = sum of the left term R4 = sum of the right term R5= b. (r or n-r whichever is smaller) R6= a-b+1 R7 = counter Program: 1. 1 2. STO 7 3. 0 4. STO 3 5. STO 5 6. RCL 1 7. RCL 2 8. - 9. RCL 2 10. x<=y 11. GTO 13 12. GTO 15 13. RCL 2 14. GTO 18 15. RCL 1 16. RCL 2 17. - 18. STO 5 19. CHS 20. RCL 1 21. + 22. 1 23. + 24. STO 6 25. RCL 6 26. LN 27. 1 28. 0 29. LN 30. / 31. STO+ 3 32. 1 33. RCL 6 34. + 35. STO 6 36. RCL 1 37. RCL 6 38. x<=y 39. GTO 25 40. RCL 7 41. LN 42. 1 43. 0 44. LN 45. / 46. STO+ 4 47. 1 48. RCL 7 49. + 50. STO 7 51. RCL 5 52. RCL 7 53. x<=y 54. GTO 40 55. RCL 3 56. RCL 4 57. - 58. 1 59. 0 60. x<>y 61. y^x 62. GTO 00 ``` Re: HP-300s cannot do nCr for many allowable values - Eddie W. Shore - 10-31-2010 ```Thanks, Marcus. :) I have to remember to do the HTML code. ``` Edited: 31 Oct 2010, 11:11 a.m.