hp 28s, hp48 sx, hp 48gx « Next Oldest | Next Newest »

 ▼ elgar Junior Member Posts: 4 Threads: 1 Joined: Jan 1970 05-01-2004, 01:06 PM I look for programs that generate (randomly) n natural numbers without repetitions with n greater or equal to 1 and smaller or equal to N (N being a positive integer.) Thank you for your help. ▼ Vieira, Luiz C. (Brazil) Posting Freak Posts: 4,027 Threads: 172 Joined: Aug 2005 05-01-2004, 01:27 PM Hi, elgar; All the calculators you mentioned already have a built-in pseudo Random Number generator that uses a seed you can type in. The command to generate a pseudo Random number (to level 1) is [RAND] and the command to "collect" a seed (a real number in Level 1) is [RDZ] (randomize). Using RPL You can type in the following program:```« -> N « RAND N * IP » »``` You can store it with a private name (e.g.: 'MYRAND' [STO]). Also, maybe you probably know about this, but there is no harm mentioning: the [->] symbol refers to the single right-arrow, not a composition of a minus with a greater-than sign. Just for the records and for my own sake... IP returns the integer part (truncates, no rounding) of the resulting value from RAND (pseudo Random number) times N (your "range"). In this case, N must be in Level 1 prior to execute the program. If you want the program to use an specific N everytime you run it, use only this part:```« RAND N * IP »``` You should store a value in N prior to execute it. Anytime you need to change the range, you simply type the new value for N and press 'N' [STO]. Also, for changing the pseudo sequence, you just type in a real number and execute [RDZ]. Hope this helps. Luzi (Brazil) Edited: 1 May 2004, 1:33 p.m. ▼ elgar Junior Member Posts: 4 Threads: 1 Joined: Jan 1970 05-01-2004, 05:38 PM Thank you for your swift help; I look for a program (or programs) that prompts for N and n (n> 'NRAND' STO Then: << -> n << n 1. { } -> l << DUP2 SWAP FOR k k NEXT n ->LIST UNROT FOR r r NRAND DUP2 DUP2 1 - 1 SWAP SUB UNROT 1 + OVER SIZE SUB + UNROT GET 'l' SWAP STO+ -1. STEP DROP l AXL >> >> >> 'LRAN' STO 'LRAN' RCL BYTES => # 830Dh 166.5 Note: I wrote this in the wee-wee hours. It works (for all 1..N) but is not optimized. You could also use the randomizer to pick up an item to be "sorted" as the first element of a list, then the second, etc. [VPN] ▼ elgar Junior Member Posts: 4 Threads: 1 Joined: Jan 1970 05-02-2004, 05:52 AM Thank you very much indeed for your kindness and patience. I have not yet coded it in, I hope it will work. ▼ V-PN Posting Freak Posts: 785 Threads: 13 Joined: Jan 2005 05-02-2004, 06:24 PM Be aware! This "solution" simply picks randomly all numbers between 1..N [VPN]

 Possibly Related Threads... Thread Author Replies Views Last Post HP-48GX & 50G Question Matt Agajanian 2 623 12-08-2013, 10:17 PM Last Post: Matt Agajanian HP Prime... NOT meant to replace HP48,49,50 ? Chris Pem10 21 1,950 11-18-2013, 03:30 PM Last Post: Chris Smith BATTERIES' SWAP ON HP 48GX aurelio 7 965 10-06-2013, 07:50 PM Last Post: aurelio Missing LCD segments (48 SX) Matti Övermark 2 520 09-18-2013, 03:50 PM Last Post: Matti Övermark Riemann's Zeta Function update (HP-28S, HP-48G/GX/G+, HP-49G/G+/50g) Gerson W. Barbosa 0 385 06-30-2013, 01:01 AM Last Post: Gerson W. Barbosa SpeedBrowser / EQLib Browser for the HP 48S/SX Raymond Del Tondo 0 336 04-21-2013, 11:09 AM Last Post: Raymond Del Tondo Riemann's Zeta Function (HP-28S) Gerson W. Barbosa 8 887 02-03-2013, 03:23 PM Last Post: Gerson W. Barbosa HP 48GX with Black LCD - S/N ID Jeff Kearns 4 630 12-15-2012, 03:55 PM Last Post: aurelio Error Message/Procedure HP-48SX with TDS Survey SX card bporter101 6 789 12-10-2012, 10:18 AM Last Post: bporter101 Archive an HP 50G and Restore on an HP 48GX Rudy P. 5 718 11-16-2012, 09:24 PM Last Post: Michael Lopez

Forum Jump: