English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

For example: The program begins "PROMPT N"; I store 24 for "N"; and by the time the program finishes, I get a list that reads "1,2,3,4,6,8,12,24". Thanks for the help.

2006-10-10 13:43:26 · 1 answers · asked by Bob 3 in Science & Mathematics Mathematics

1 answers

I'm betting that TI Basic isn't too different from plain basic, so you can adapt this:

PROMPT N
PRINT 1;
for i = 2 to N
if INT(N/i) = N/i then PRINT ","; i;
next i

(Note semicolon in PRINT statement prevents a line feed.)
If for some reason the test "if INT(N/i) = N/i" doesn't work reliably it would be because the floating point representation of an integer value doesn't equal an exact integer. This doesn't happen in plain basic, but it might in TI basic. If so, you can use the test
"if ABS(INT(N/i) - N/i) < epsilon" (where epsilon is some very small number, say .00001).

2006-10-10 14:26:19 · answer #1 · answered by kirchwey 7 · 1 0

fedest.com, questions and answers