Factors of an integer: Difference between revisions

m
→‎{{header|Quackery}}: changed name of word
(→‎{{header|Quackery}}: added link to Isqrt (integer square root) of X)
m (→‎{{header|Quackery}}: changed name of word)
Line 5,859:
=={{header|Quackery}}==
 
<code>sqrt+</code> is defined at [[Isqrt (integer square root) of X#Quackery]]. It returns the integer square root and remainder (i.e. the square root of 11 is 3 remainder 2, because three squared plus two equals eleven.) If the number is a perfect square the remainder is zero. This is used to remove a duplicate factor from the list of factors which is generated when finding the factors of a perfect square.
 
The nest editing at the end of the definition (i.e. the code after the <code>drop</code> on a line by itself) removes a duplicate factor if there is one, and arranges the factors in ascending numerical order at the same time.
 
<syntaxhighlight lang="text"> [ [] swap
dup sqrt+ 0 = dip
[ times
[ dup i^ 1+ /mod iff
1,462

edits