Integer part and other little tricks (CASIO fx50F)

02142017, 11:53 PM
Post: #1




Integer part and other little tricks (CASIO fx50F)
I found a little quiz on a Hungarian forum and I found my earlier solution to CASIO fx602P. I decided that I will solve this tiny problem on my 50F  I did not think that it will cause many trouble for me.
The quiz: It is possible to add two square number to get the number of this year? A^2+B^2=2017 > A,B=? OK, this is not a big deal, let's go from B=0 to B=INT(SQRT(2017/2))=31, and calculate A=SQRT(2017B^2) and check A==INT(A) or not. If yes, we found a solution. How we can check a number is an integer or not? It is simple: if the fractional part of the number is greater than zero, the number is not an integer. This is OK for this calculator because on the 50F only two condition is available: x>0 and x<=M. The problem is that, on the 50F has no FRAC() function, but we can calculate it as FRAC(A)=AINT(A), but on the 50F has no INT() also. First idea  FIX 0 and RND This is the obvious solution: use the FIX function and then round the number, but when you select FIX 0, the calculator rounds the display and you can not to check the fractional part of the 'A' is positive or not: Code:
After few trying with FIX and RND I can see that this is not a solution. I need something which use only integers. Maybe the BASEN mode? Yesss...! Third idea (second doesn't count)  INT() with BASEN Code:
Yes, slightly imperfect, just try it: if we has no solution this will never stops, because the program never checks the value of B>0? Unfortunately on the 50F if a condition is true the program restarted on the first step, so we need to check B<0 and stop if this is true, but if B>=0, we need to run the program. Fourth idea  how to make a condition with true AND false Code:
This is works as I want and stops with an error if you have no solution or you have a solution but the Year is not a square number, or stops with 0 on the display if the Year is a square number. Thanks for reading  I'm waiting for similar little tricks which are really useful during programming on a very limited memory. Csaba 

02152017, 02:52 PM
(This post was last modified: 02152017 04:39 PM by xerxes.)
Post: #2




RE: Integer part and other little tricks (CASIO fx50F)
Some of the CASIOs with this type of keystroke programming have no BASEN mode, so here a solution for the FX180P in 17 steps:
Code: 1 Input: Year in K1 and zero in K2 Output: A and B in K2 and K3 The program stops with 0, if a solution is found or gives an error, if not. Calculator Benchmark 

02152017, 08:45 PM
Post: #3




RE: Integer part and other little tricks (CASIO fx50F)
OK, the two solution is not comparable, because you don't check the IP of the square root=0, you check the FP>0. This is works on the 50F also, but you can feel that FIX0+RND is works but this is a cheating
BTW checking the end of the loop with only one x>0 is more elegant and you do not need to decide the max value of loop counter  but you will get all the solutions twice. Thanks for this elegant, simplest and more portable code. If I collect my 50F codes into a short document can I share this version with your nick?! Have you got any other little code for these blind programmable calcs?! Csaba 

02162017, 09:00 AM
Post: #4




RE: Integer part and other little tricks (CASIO fx50F)
I have most of the casios of that generation. i never understood why someone would want not a doiftrue or even skipiftrue, but a restartiftrue condition... combined with a very low number of storable steps and only two possible conditions (x>0 and x<=M), that 50f was a very quirky device.


02162017, 02:46 PM
Post: #5




RE: Integer part and other little tricks (CASIO fx50F)
(02152017 08:45 PM)Csaba Tizedes Wrote: OK, the two solution is not comparable, because you don't check the IP of the square root=0, you check the FP>0. This is works on the 50F also, but you can feel that FIX0+RND is works but this is a cheating The logic in the FX180P version is, if there is a difference between X and ROUND(X), that saves one step. The combination of FIX0, RND und NORM is very useful and it can be seen as a programming trick, because it is not mentioned in any CASIO manual. A more obvious trick is using x^2 and SQRT, due to the missing ABS. A size optimized program for the greatest common divisor, that makes use of it: Code: 01 x<>y Usage example: 861   615 P1 (02152017 08:45 PM)Csaba Tizedes Wrote: Have you got any other little code for these blind programmable calcs?! Another one is Viète's formula on the FX180P: Code: P1: Usage example: 10 P1 P2 or Fun with the Casio fx180p / fx3600p (02152017 08:45 PM)Csaba Tizedes Wrote: If I collect my 50F codes into a short document can I share this version with your nick?! Yes,of course. Nice to see that you like the programming on this very limited devices. Calculator Benchmark 

02192017, 04:20 PM
Post: #6




RE: Integer part and other little tricks (CASIO fx50F)
(02162017 02:46 PM)xerxes Wrote: A size optimized program for the greatest common divisor, that makes use of it: Hello Xerxes! Please check your GCD routine above  is it works, are you sure?! Pls. clarify the Usage again! I need something similar, please read this: Inverse Fibonacci Sums (MoHPC). Your opinion?! Thanks! Csaba 

02192017, 05:27 PM
Post: #7




RE: Integer part and other little tricks (CASIO fx50F)
Hi Csaba,
I've checked the code and it works like it should. If I type in "861 minus minus 615 P1", the output is 123. The trick is to use a pending operator in the program loop, if possible. I'll check the Inverse Fibonacci Sums on the FX180P. Calculator Benchmark 

02202017, 09:01 AM
Post: #8




RE: Integer part and other little tricks (CASIO fx50F)
(02192017 05:27 PM)xerxes Wrote: "861 minus minus 615 P1", the output is 123.Uhh..., I have tested and that was a flash in my mind, when I pressed two times the [] minus key and the 'K  Constant calculation' is lit on the LCD. I need to study this little program step by step... (02192017 05:27 PM)xerxes Wrote: I'll check the Inverse Fibonacci Sums on the FX180P.Thanks! Csaba 

02202017, 01:47 PM
Post: #9




RE: Integer part and other little tricks (CASIO fx50F)
Another way is using the K vars, instead of the pending operator:
Code: 01 Kin1 Usage example: 861 Kin1 615 P1 Calculator Benchmark 

03162017, 04:11 PM
(This post was last modified: 03172017 01:08 PM by xerxes.)
Post: #10




RE: Integer part and other little tricks (CASIO fx50F)
An interesting exercise from a french pocket and calculator forum is the Collatz conjecture, thats pretty simple to implement normally.
First I was not sure, if it's also possible on the very limited FX180P, but it was. The real challenge however, was to reduce the steps to 29 bytes or less, to fit in the FX50F too: Code: 01 2 Usage example: KAC Min 13 Kin1 P1 program stops with error Kout3 > 9 (length) MR > 40 (maximum) Calculator Benchmark 

03172017, 11:36 AM
Post: #11




RE: Integer part and other little tricks (CASIO fx50F)
(03162017 04:11 PM)xerxes Wrote: from a french pocket and calculator forum Thanks, can you share the link here?! (03162017 04:11 PM)xerxes Wrote: Collatz conjecture, ... to reduce the steps to 29 bytes or less, to fit in the FX50F: OK, I will check it  unfortunately RTN is not available on fx50F Csaba 

03172017, 01:33 PM
Post: #12




RE: Integer part and other little tricks (CASIO fx50F)
Hi Csaba,
I was able to optimize a litte for speed and size with 27 bytes now. You can replace the RTN with x>0. Can you please check the execution time on the FX50F for 27? The FX3900PV needs 11.3 seconds. The link to the discussion: http://www.silicium.org/forum/viewtopic....46&t=36995 Calculator Benchmark 

03172017, 11:02 PM
(This post was last modified: 03182017 07:51 AM by Csaba Tizedes.)
Post: #13




RE: Integer part and other little tricks (CASIO fx50F)
[edit]3400P added!
(03172017 01:33 PM)xerxes Wrote: Can you please check the execution time on the FX50F for 27? The FX3900PV needs 11.3 seconds. The results: Code: CASIO fx10F: 7.30s / 7.29s / 7.29s > aver= 7.3s Thanks for the link! Csaba 

03182017, 12:50 PM
Post: #14




RE: Integer part and other little tricks (CASIO fx50F)
Thank you for the results. If you like this CASIO series, you will love the FX3900Pv or the FX180P Plus.
These are much faster and you have 300 steps in 4 areas. Additionally they offer a nice editing mode, so it's not necessary to program in the blind any more. I assume, that your results are for 13 and not 27. If so, the FX3900Pv needs about 0.9 seconds. Calculator Benchmark 

03202017, 09:43 PM
Post: #15




RE: Integer part and other little tricks (CASIO fx50F)
(03182017 12:50 PM)xerxes Wrote: Thank you for the results. If you like this CASIO series, you will love the FX3900Pv or the FX180P Plus.Yes, this was the 13 Kin1. The 27 was a little misunderstood, because the length of the program decreased to 27 steps and the example was 13. I'll check it with 27 Kin1 also. Csaba 

03232017, 09:22 AM
Post: #16




RE: Integer part and other little tricks (CASIO fx50F)
On fx50F:
Code: [KAC] [Min] 27 [Kin] 1 [P1] Csaba 

03062019, 10:22 PM
Post: #17




RE: Integer part and other little tricks (CASIO fx50F)
Uhh, this was WTF  but I found why SD mode is required... Check in YT and read my comment below the video.
Csaba 

« Next Oldest  Next Newest »

User(s) browsing this thread: 1 Guest(s)