Post Reply 
How to run an expression in CAS mode in program
06-23-2017, 12:49 PM
Post: #1
How to run an expression in CAS mode in program
I have a program I'm running and I'm having a problem getting a line in the program to run in CAS mode. Breaking the line down to it's simplest form is like this...
t:=(a^(n-1)) MOD n;
...where a = 503, n = 29.
When I single step through my program, I get that t = 6 after this line is executed (wrong answer).
Now, when I just go to the home view and run the following, (503^28) MOD 29;
...the result is 6.

When I press the CAS button to put it in CAS view and execute the same line, I get a result of 1 (correct result).

I know WHAT the problem is. It's that in CAS mode, I have a resolution of 2500 digits or so, but in home view it limits it to 13 digits or whatever it is....giving me the wrong answer.
How do I force it to run the line (t:=(a^(n-1)) MOD nWink in CAS mode while in a program?
I tried pressing the CAS button before entering the program debug and single stepping, but it gives me 6 every time.
Is it simply the matter of entering CAS.MOD instead of MOD or something like that?
I guess I could create a separate CAS program (with the CAS checkbox checked) and put a function in there that executes that line, and call it from the other program...would that work?
The problem is that I am unsure if it's wise to just check the CAS box in my program as I have multiple programs under the one name and some of these need to run in home view.
Another thought is that I can create a #cas #end block in the same program...without checking the CAS box....is that allowed?
I know I can try all of these options, but that will require my rewriting the code multiple times for each of these options. If someone knows the answer, they could save me a lot of time....I'd be grateful for anyone who knows the solution to this problem.
Thanks in advance.
-Donald
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
How to run an expression in CAS mode in program - webmasterpdx - 06-23-2017 12:49 PM



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