05-30-2017, 09:08 AM
I want to use long integer values in a program. On the CAS home screen, I can define:
* A:=1000!;
and it stores the exact value into that variable.
I've tried methods I saw on various web pages, like
* calling the variables CAS.B and CAS.D
* CAS.B:=19^C-1;
**** (I still got scientific notation when the numbers got too large)
when that didn't work, I tried
* CAS("B:=19^C-1");
**** but this still gave me scientific notation after a certain point.
I'd love to know how to use CAS precision variables in a program if anyone can point me to the information.
Here's the latest version of the program. It is meant to simply give the 2^E and 3^F prime factors of 19^C-1.
(I don't know why this COPY of the program gets double ;; when I only used single ;. I assume there are some places where the ; is optional that I used it, so it was doubled when transferred to the computer. There are also some cases where I have ; in the calcuator and it was deleted when copied to the computer, like in both IF ... END blocks.)
* A:=1000!;
and it stores the exact value into that variable.
I've tried methods I saw on various web pages, like
* calling the variables CAS.B and CAS.D
* CAS.B:=19^C-1;
**** (I still got scientific notation when the numbers got too large)
when that didn't work, I tried
* CAS("B:=19^C-1");
**** but this still gave me scientific notation after a certain point.
I'd love to know how to use CAS precision variables in a program if anyone can point me to the information.
Here's the latest version of the program. It is meant to simply give the 2^E and 3^F prime factors of 19^C-1.
Code:
#cas
P18NSUB1():=
BEGIN
FOR C FROM 1 TO 15 DO
CAS("B:=19^C-1");
CAS("D:=B");
E:=0;
F:=0;
G:=0;
WHILE G = 0 DO
CAS("G:=D MOD 2");
IF G = 0 THEN
E:=E+1;
D:=D/2 END ;
END;;
G:=0;
WHILE G = 0 DO
CAS("G:=D MOD 3");
IF G = 0 THEN
F:=F+1;
D:=D/3 END ;
END;;
PRINT(1000*E+F+C/1000);
PRINT(B);
PRINT(-D);
END;;
RETURN(B);
END;
#end
(I don't know why this COPY of the program gets double ;; when I only used single ;. I assume there are some places where the ; is optional that I used it, so it was doubled when transferred to the computer. There are also some cases where I have ; in the calcuator and it was deleted when copied to the computer, like in both IF ... END blocks.)