Algorithm for converting fraction into (recurring) decimal

I need to determine whether fraction is recurring decimal or not (what are conditions for it?), find period and output it as $\frac{1}{3}=0.\overline{3}$

If it is not recurring, then I already have algorithm.

I need to determine whether fraction is recurring decimal or not (what are conditions for it?), find period and output it as $\frac{1}{3}=0.\overline{3}$

If it is not recurring, then I already have algorithm.