▁f ▁= ▁ 3 ▁▁▁▁ ▁while ▁f ▁* ▁f ▁<= ▁n : ▁▁▁▁▁▁▁▁ ▁if ▁n ▁% ▁f ▁== ▁ 0 : ▁▁▁▁▁▁▁▁▁▁▁▁ ▁a . append ( f ) ▁▁▁▁▁▁▁▁▁▁▁▁ ▁n ▁/ = ▁f ▁▁▁▁▁▁▁▁ ▁else : ▁▁▁▁▁▁▁▁▁▁▁▁ ▁f ▁+= ▁ 2 ▁▁▁▁ ▁if ▁n ▁!= ▁ 1 : ▁a . append ( n ) ▁▁▁▁ ▁# ▁Only ▁odd ▁number ▁is ▁possible ▁▁▁▁ ▁return ▁a ▁▁ ▁These ▁versions ▁of ▁trial ▁division ▁are ▁guaranteed ▁to ▁find ▁a ▁factor ▁of ▁n ▁if ▁there ▁is ▁one ▁since ▁they ▁check ▁all ▁possible ▁factors ▁of ▁n ▁- ▁and ▁if ▁n ▁is ▁a ▁prime ▁number , ▁this ▁means ▁trial ▁factors ▁all ▁the ▁way ▁up ▁to ▁n . ▁Thus , ▁if ▁the ▁algorithm ▁finds ▁one ▁factor ▁only , ▁n , ▁it ▁is ▁proof ▁that ▁n ▁is ▁a ▁prime . ▁If ▁more ▁than ▁one ▁factor ▁is ▁found , ▁then ▁n ▁is ▁a ▁composite ▁integer . ▁A ▁more ▁computation ally ▁advantage ous ▁way ▁of ▁saying ▁this ▁is , ▁if ▁any ▁prime ▁whose ▁square ▁does ▁not ▁exceed ▁n ▁div ides ▁it ▁without ▁a ▁remainder , ▁then ▁n ▁is ▁not ▁prime . ▁ ▁Speed ▁In ▁the ▁worst ▁case , ▁trial ▁division ▁is ▁a ▁labor ious ▁algorithm . ▁For ▁a ▁base - 2 ▁n ▁digit ▁number ▁a , ▁if ▁it ▁starts ▁from ▁two ▁and ▁works ▁up ▁only ▁to ▁the ▁square ▁root ▁of ▁a , ▁the ▁algorithm ▁requires ▁ ▁trial ▁divisions , ▁where ▁ ▁denotes ▁the ▁prime - count ing ▁function , ▁the ▁number ▁of ▁pr imes ▁less ▁than ▁x . ▁This ▁does ▁not ▁take ▁into ▁account