www.delorie.com/gnu/docs/calc/calc_57.html | search |
Buy the book! | |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
The obvious first step is to obtain the list of factors with k f. This list will always be in sorted order, so if there are duplicates they will be right next to each other. A suitable method is to compare the list with a copy of itself shifted over by one.
1: [3, 7, 7, 7, 19] 2: [3, 7, 7, 7, 19] 2: [3, 7, 7, 7, 19, 0] . 1: [3, 7, 7, 7, 19, 0] 1: [0, 3, 7, 7, 7, 19] . . 19551 k f RET 0 | TAB 0 TAB | |
1: [0, 0, 1, 1, 0, 0] 1: 2 1: 0 . . . V M a = V R + 0 a = |
Note that we have to arrange for both vectors to have the same length so that the mapping operation works; no prime factor will ever be zero, so adding zeros on the left and right is safe. From then on the job is pretty straightforward.
Incidentally, Calc provides the Moebius mu function which is zero if and only if its argument is square-free. It would be a much more convenient way to do the above test in practice.
webmaster donations bookstore | delorie software privacy |
Copyright © 2003 by The Free Software Foundation | Updated Jun 2003 |