Simplest Radical Form in Ti-Nspire Calculator Programming Language

closed account (SEbXoG1T)
Hello, I recently bought a TI-Nspire CX calculator, and i was wondering what the syntax for Simplest Radical From is, so I can write a program to simplify radicals. The Language is quite easy, and if you could give me the C++ equivalent, I should be able to translate it.

Please help,
JG16477
Here's something
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
int x = 12;
int cx = x;
int counter = 0;
int a = 1, b;

for( int i = 2; i < x; ) {
   if( x % i == 0 ) {
      counter ++;
      x /= i;

      if( counter == 2 ) {
         a *= i;
         counter = 0;
      }
   } else {
      counter = 0;
      i++;
   }
}
b = cx/(a*a);

This is for square roots. sqrt(x) is simplified to a*sqrt(b). The idea is to find all prime factors and check if any of them are repeated twice. In that case, you'd multiply a by that factor. b can be computed later.
If you want this to work for nth degree root, replace "counter == 2" with "counter == n" and "b = cx/(a*a)" with "b = cx/prod" where prod is an, computed in a for loop.
Topic archived. No new replies allowed.