Factors of an integer: Difference between revisions

(→‎{{header|PureBasic}}: Added PureBasic)
Line 535:
'((D) (=0 (% N D)))
(range 1 N) ) )</lang>
=={{header|PureBasic}}==
<lang PureBasic>Procedure PrintFactors(n)
Protected i, lim=Round(sqr(n),#PB_Round_Up)
NewList F.i()
For i=1 To lim
If n%i=0
AddElement(F()): F()=i
AddElement(F()): F()=n/i
EndIf
Next
;- Present the result
SortList(F(),#PB_Sort_Ascending)
ForEach F()
Print(str(F())+" ")
Next
EndProcedure
 
If OpenConsole()
Print("Enter integer to factorize: ")
PrintFactors(Val(Input()))
Print(#CRLF$+#CRLF$+"Press ENTER to quit."): Input()
EndIf</lang>
'''Output can look like
<tt>
Enter integer to factorize: 96
1 2 3 4 6 8 12 16 24 32 48 96
</tt>
 
=={{header|Python}}==
Anonymous user