Hello everyone. Is there any way to easily calculate all possible fractions of a number using ti nspire CAS?
For example, I enter number 100 and receive output 1, 2, 4, 5, 10, 20, 25, 50, 100. Thanks!
Input "NUMBER?", A
{1→L₁
For(B,2,A/2
if not(fPart(A/B
B→L₁(1+dim(L₁
End
L₁
Hope this helps ;) Oh, keep in mind, this does not return the last factor; that is, the number itself. If you use your example, when you set A to 100, L1 becomes {1, 2, 4, 5, 10, 20, 25, 50}. Just so you know
Yeah it's pretty simple actually. Here's the code for it:
Input "Number?",A
int(A/2)->B
1->dim(L1)
For(C,1,B
If int(A/C)=A/C
Then
C->L1(dim(L1))
dim(L1)+1->dim(L1)
End
End
dim(L1)-1->dim(L1)
For(A,1,dim(L1
Disp L1(A)
End
L1
And yeah hope that helps, it'll find all the factors of any one number. Funny thing is that when I first went to make this program like a few minutes ago I apparently had already made a similar factoring program and had just left it in archive and forgot about it. It doesn't find the factors of one number but instead finds all the common factors of 2 numbers. Let me know if you want the code for that too. So yea, pretty cool stuff.