I have a problem how to convert number 0.3333....3 where 3 repeats N times to fraction.

for N=1 0.3

N=2 0.33 and so on.

I know how to convert number where digits repeats forever, but how can I convert this to fraction to get correct result for any N.

Thanks in advance