Here is an Algorithm to help you handle both cases, Try it and feel free to ask about how it works

```
function repeated(n::Int)
q = n
tows, fives = 0, 0
while q % 2 == 0
q = q ÷ 2
tows += 1
end
while q % 5 == 0
q = q ÷ 5
fives += 1
end
d = max(tows, fives)
k = 1
if q == 1
ans = reverse(digits(trunc(Int, 10^d * 1/n)))
return [zeros(Int, d - length(ans) + 1); ans], d + 1
end
while true
if 10^k % q == 1
ans = reverse(digits(trunc(Int, 10^(d+k) * 1 / n)))
return [zeros(Int, k + d - length(ans) + 1) ;ans], k + d - length(ans) + 2
end
k += 1
end
end
```

Some tests

```
julia> repeated(7)
([0, 1, 4, 2, 8, 5, 7], 2)
julia> repeated(6)
([0, 1, 6], 2)
julia> repeated(5)
([0, 2], 2)
julia> repeated(24)
([0, 0, 4, 1, 6], 3)
julia> repeated(128)
([0, 0, 0, 7, 8, 1, 2, 5], 8)
```

Benchmark

```
julia> @benchmark repeated(6)
BenchmarkTools.Trial: 10000 samples with 193 evaluations.
Range (min … max): 504.870 ns … 1.217 ms ┊ GC (min … max): 0.00% … 99.92%
Time (median): 516.606 ns ┊ GC (median): 0.00%
Time (mean ± σ): 680.181 ns ± 12.190 μs ┊ GC (mean ± σ): 20.54% ± 2.58%
█▄
▂███▆▃▂▂▂▂▂▂▂▂▂▂▂▂▂▄▇█▆▄▃▂▂▂▂▂▂▂▂▂▂▂▂▂▂▁▂▂▂▂▂▂▂▂▂▂▂▂▁▂▁▁▂▂▂▂ ▃
505 ns Histogram: frequency by time 694 ns <
Memory estimate: 304 bytes, allocs estimate: 4.
julia>
```