Integer part and other little tricks (CASIO fx-50F)
|
02-14-2017, 11:53 PM
Post: #1
|
|||
|
|||
Integer part and other little tricks (CASIO fx-50F)
I found a little quiz on a Hungarian forum and I found my earlier solution to CASIO fx-602P. 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(2017-B^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)=A-INT(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 BASE-N mode? Yesss...! Third idea (second doesn't count) - INT() with BASE-N 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 |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)