Prime Factors in the ALPHA REG. - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: Not HP Calculators (/forum-7.html) +--- Forum: Not quite HP Calculators - but related (/forum-8.html) +--- Thread: Prime Factors in the ALPHA REG. (/thread-5276.html) Pages: 1 2 Prime Factors in the ALPHA REG. - ggauny@live.fr - 12-05-2015 09:19 AM Hi, I am think have found what I was wanted to find, that it is : To see in first line of display : PRIME FACTORS in good mathematic presentation TO see in 2nd line of display : The integer wich is PRIME FACTORED. I reach do this this night, but it is not runing well as far. If I reach good I will put in forum. I put a result in attachement. RE: Prime Factors in the ALPHA REG. - ggauny@live.fr - 12-05-2015 12:46 PM Hi, The difficulty is to translate the codes to input in ALPHA REGISTER. A way to do this is go in base HEX, for instance the exponant sign is 5E in the array of code characters in manual, 2 is 32 in array which is HEXA, SPACE is 06 in the array, so I go HEXA I put the code hexa of what I want, for example : 2^2[space] I do 32 x->a 5e x->a 32 x->a, it is "2^2" in alpha register. Of course I have made a routine for translate what I need ! numbers 2 to 9 (it is sufficient I think), and ^, ., SPACE, after I display alpha register and I have my result. RE: Prime Factors in the ALPHA REG. - Dieter - 12-08-2015 09:23 PM (12-05-2015 12:46 PM)ggauny@live.fr Wrote:  The difficulty is to translate the codes to input in ALPHA REGISTER. Why should one want to do this? Codes? Why do you want to use codes ?-) (12-05-2015 12:46 PM)ggauny@live.fr Wrote:  A way to do this is go in base HEX, for instance the exponant sign is 5E in the array of code characters in manual, 2 is 32 in array which is HEXA, SPACE is 06 in the array, so I go HEXA I put the code hexa of what I want, for example : 2^2[space] I do 32 x->a 5e x->a 32 x->a, it is "2^2" in alpha register. Of course I have made a routine for translate what I need ! numbers 2 to 9 (it is sufficient I think), and ^, ., SPACE, after I display alpha register and I have my result. Maybe I do not understand why you want to use such a complicated method. But why don't you just directly append the characters and numbers you want? Let's assume the factor is in register 1 and the exponent in register 2, why don't you simply do it this way: Code: ```αIP 01 "^" αIP 02``` Remember: unlike the HP41, there is no "append" character on the 34s. Every alpha entry is automatically appended to the existing alpha string. So you always have to use CLα if you want to start a new alpha string. The exponent character "^" is in the alpha calatog at [f] [→], a space is [h] [0] (=PSE) and a multiplication symbol is also available at [f] [x]. However, I did not find a centered dot like "·". Walter? Anyway, the 34s alpha display is of not much use here as the number of displayed characters is very limited. Unlike the HP41, the display does not scroll. Dieter RE: Prime Factors in the ALPHA REG. - walter b - 12-09-2015 07:22 AM (12-08-2015 09:23 PM)Dieter Wrote:  However, I did not find a centered dot like "·". Walter? There is no center dot provided on the WP 34S - there will be one on the WP 43S. d:-) RE: Prime Factors in the ALPHA REG. - Dieter - 12-09-2015 01:05 PM (12-08-2015 09:23 PM)Dieter Wrote:  Anyway, the 34s alpha display is of not much use here as the number of displayed characters is very limited. Unlike the HP41, the display does not scroll. Output on a single line may be shortened by using the ² and ³ characters. Which can be done in a dedicated output routine. But even this way results with more than 10 or 11 characters can not be displayed – everything beyond that simply is not shown. This may be solved by removing the first characters until the output line does not exceed this limit: Code: ```αLENG #010 - x>0? αSL→X``` A more sophisticated version may remove the first characters until it comes across a "×": Code: ```  2^5×5^3×7 → …5^3×7×41``` These problems with single-line output are the reason why I prefer the following method: Code: ```492000 XEQ"PRF"                 2^5        [R/S]    ×3        [R/S]    ×5^3        [R/S]    ×41``` Simple and straightforward. ;-) Dieter RE: Prime Factors in the ALPHA REG. - fhub - 12-09-2015 02:33 PM (12-09-2015 01:05 PM)Dieter Wrote:  Simple and straightforward. ;-) But what if the number itself is a prime with more than 11 digits, e.g. 100000000003? You can't completely show it in the alpha display, so if you really want to get prime factor with their exponent, then I guess the only way would be to display the prime factor in X and then exponent in alpha. Franz RE: Prime Factors in the ALPHA REG. - Dieter - 12-09-2015 06:29 PM (12-09-2015 02:33 PM)fhub Wrote:  But what if (...) You can't (...) Yes, you can't. Choose any method, and there will be a limit where it doesn't work. One more reason to return the prime factors one at a time (via R/S). Or use a printer. Apropos: the 34s seems to behave differenlty compared to the 41-series (and maybe also the 42s) in that the VIEW commands (including AVIEW resp. VIEWα and VWα+) do not print, so that a separate print command is required if output should also appear on the printer. The [printer]? test command does not help much here as it does not test whether a printer is connected and ready or not. There is no equivalent to the 41/42 flags 21 and 55. Maybe all this can be improved in, err... "future projects". ;-) Dieter RE: Prime Factors in the ALPHA REG. - fhub - 12-09-2015 06:32 PM (12-09-2015 06:29 PM)Dieter Wrote:  Yes, you can't. Choose any method, and there will be a limit where it doesn't work. One more reason to return the prime factors one at a time (via R/S). Yes, here's the way I would do it (separated primefactors in X and exponents in alpha), thus no limit to 11 digits - it's just a modification of my old 'PF' in the WP34s library: Code: ``` /*   Prime Factorization:  list of 'true' prime factors (1? .03 0014 SKIP 013 0015 [cmplx]ENTER 0016 MOD 0017 x=0? 0018 SKIP 005 0019 DROP 0020 INC X 0021 EVEN? 0022 INC X 0023 BACK 010 0024 DROP 0025 XEQ 00 0026 STO/ Y 0027 BACK 019 0028 DROP 0029 XEQ 00 0030 CLSTK 0031 RCL .00 0032 LBL 00 0033 x[!=]? .01 0034 SKIP 002 0035 INC .02 0036 SKIP 011 0037 # 001 0038 RCL Y 0039 [cmplx]x[<->] .01 0040 x=0? 0041 SKIP 005 0042 CL[alpha] 0043 [alpha] ^ 0044 [alpha]IP Y 0045 PROMPT 0046 CL[alpha] 0047 [cmplx]DROP 0048 END``` Franz RE: Prime Factors in the ALPHA REG. - Marcus von Cube - 12-09-2015 07:33 PM (12-09-2015 06:29 PM)Dieter Wrote:  The [printer]? test command does not help much here as it does not test whether a printer is connected and ready or not. There is no equivalent to the 41/42 flags 21 and 55. Maybe all this can be improved in, err... "future projects". ;-) Sorry, but the IR printer cannot talk back to the calculator so there is no chance to check if the printer is ready. The [printer]? test command just tells whether the correct firmware for printing is installed. RE: Prime Factors in the ALPHA REG. - walter b - 12-09-2015 08:10 PM Please allow me to quote the entry for ⎙? in the IOP of the manual:Quote:Tests if a quartz crystal and the necessary firmware are installed for printing. I.e. ⎙? will return true if XTAL? returns true and calc_ir.bin (or calc_ir_full.bin) is loaded. The IR diode must be checked visually. HTH d:-) RE: Prime Factors in the ALPHA REG. - Dieter - 12-09-2015 09:33 PM (12-09-2015 08:10 PM)walter b Wrote:  Please allow me to quote the entry for ⎙? in the IOP of the manual: Walter, I know very well what the [printer]? test does – and what it doesn't. That's exactly my point: There is no way of checking whether a printer is connected and ready or not. Dieter RE: Prime Factors in the ALPHA REG. - walter b - 12-10-2015 07:48 AM Fine. We can agree on that. d:-) RE: Prime Factors in the ALPHA REG. - Marcus von Cube - 12-10-2015 11:06 AM (12-09-2015 09:33 PM)Dieter Wrote:  There is no way of checking whether a printer is connected and ready or not. And we have no chance to change that without different printer hardware. RE: Prime Factors in the ALPHA REG. - Dieter - 12-10-2015 05:24 PM (12-09-2015 06:32 PM)fhub Wrote:  Yes, here's the way I would do it (separated primefactors in X and exponents in alpha), thus no limit to 11 digits - Right, now the limit is at 12 digits. OK, unless you use the functions to view all mantissa digits. But if this is allowed you can just as well view the complete alpha string. ;-) BTW, is there a special reason why in this thread noone ever mentioned the NEXTP function to obtain the next divisor? Instead the programs simply test all odd divisors. #-) I have modified your program accordingly, and it still works fine. Just a bit faster. Dieter RE: Prime Factors in the ALPHA REG. - Dieter - 12-10-2015 05:35 PM (12-10-2015 11:06 AM)Marcus von Cube Wrote:   (12-09-2015 09:33 PM)Dieter Wrote:  There is no way of checking whether a printer is connected and ready or not. And we have no chance to change that without different printer hardware. Yes, I see the hardware limits. Do you see any chance to overcome this problem, e.g. for the 43s project? Is there a way to connect a different kind of printer? Dieter RE: Prime Factors in the ALPHA REG. - fhub - 12-10-2015 05:43 PM (12-10-2015 05:24 PM)Dieter Wrote:  BTW, is there a special reason why in this thread noone ever mentioned the NEXTP function to obtain the next divisor? Instead the programs simply test all odd divisors. #-) I have modified your program accordingly, and it still works fine. Just a bit faster. I remember that long time ago a member here mentioned, that NEXTP (which is still in my original version in the WP34s library) would be MUCH slower (on a real calc) than simply using INC, so I've changed this for the current version. It's strange that you state it would be faster!? Franz RE: Prime Factors in the ALPHA REG. - Marcus von Cube - 12-10-2015 06:12 PM (12-10-2015 05:35 PM)Dieter Wrote:  Do you see any chance to overcome this problem, e.g. for the 43s project? Is there a way to connect a different kind of printer? I don't know if the new hardware will support Bluetooth or USB OTG. If not, I don't see a chance. RE: Prime Factors in the ALPHA REG. - fhub - 12-10-2015 06:25 PM (12-10-2015 05:43 PM)fhub Wrote:   (12-10-2015 05:24 PM)Dieter Wrote:  BTW, is there a special reason why in this thread noone ever mentioned the NEXTP function to obtain the next divisor? Instead the programs simply test all odd divisors. #-) I have modified your program accordingly, and it still works fine. Just a bit faster. I remember that long time ago a member here mentioned, that NEXTP (which is still in my original version in the WP34s library) would be MUCH slower (on a real calc) than simply using INC, so I've changed this for the current version. It's strange that you state it would be faster!? Ok, I've now checked both versions with the emulator, I've used the biggest 12-digit primenumber 999999999989: the new version (with INC X, EVEN?, INC X) needs about 5 secs and the old version (with NEXTP) needs about 50 secs, i.e. it is 10-times slower! (I don't think this would be much different on a real WP34s) Franz RE: Prime Factors in the ALPHA REG. - Dieter - 12-10-2015 06:45 PM (12-10-2015 06:25 PM)fhub Wrote:  Ok, I've now checked both versions with the emulator, I did so with some moderate 5...8-digit primes on "real hardware". But the results are comparable: Indeed the simple INC method is much faster than NEXTP. For instance factoring 1234577 (=1x1234577 ;-)) takes about 15 vs. less than 2 seconds. I don't know how I got to my previous conclusion that NEXTP was faster – sorry, my fault. Dieter RE: Prime Factors in the ALPHA REG. - ggauny@live.fr - 12-18-2015 02:03 PM (12-08-2015 09:23 PM)Dieter Wrote:   (12-05-2015 12:46 PM)ggauny@live.fr Wrote:  The difficulty is to translate the codes to input in ALPHA REGISTER. Why should one want to do this? Codes? Why do you want to use codes ?-) (12-05-2015 12:46 PM)ggauny@live.fr Wrote:  A way to do this is go in base HEX, for instance the exponant sign is 5E in the array of code characters in manual, 2 is 32 in array which is HEXA, SPACE is 06 in the array, so I go HEXA I put the code hexa of what I want, for example : 2^2[space] I do 32 x->a 5e x->a 32 x->a, it is "2^2" in alpha register. Of course I have made a routine for translate what I need ! numbers 2 to 9 (it is sufficient I think), and ^, ., SPACE, after I display alpha register and I have my result. Maybe I do not understand why you want to use such a complicated method. But why don't you just directly append the characters and numbers you want? Let's assume the factor is in register 1 and the exponent in register 2, why don't you simply do it this way: Code: ```αIP 01 "^" αIP 02``` Remember: unlike the HP41, there is no "append" character on the 34s. Every alpha entry is automatically appended to the existing alpha string. So you always have to use CLα if you want to start a new alpha string. The exponent character "^" is in the alpha calatog at [f] [→], a space is [h] [0] (=PSE) and a multiplication symbol is also available at [f] [x]. However, I did not find a centered dot like "·". Walter? Anyway, the 34s alpha display is of not much use here as the number of displayed characters is very limited. Unlike the HP41, the display does not scroll. Dieter Hi Dieter my friend, Now at home I am able to reply, I have do this because Walter in manual say, characters are in internal codes, so of course it is complicated and health stoped my research. I had look "append" but I know it is not. At hospital, I have programed all codes for characters, but you seem saying it is not usefull. I am happy to retrieved you all !