#P7933. Divisor Counter
Divisor Counter
Divisor Counter
Given an integer \(N\), simulate the following Pascal program:
readln(N);
counter := 0;
for i := N-1 downto 1 do begin
counter := counter + 1;
if N mod i = 0 then break;
end;
writeln(counter);
The program reads an integer \(N\) and initializes a counter to zero. It then iterates from \(N-1\) down to \(1\) and, for each iteration, increments the counter. If the current integer \(i\) divides \(N\) (i.e. \(N \bmod i = 0\)), the loop is terminated. Your task is to reproduce this behavior: output the number of iterations performed before a divisor is encountered. Note that if no divisor is found in the loop (which happens when \(N\) is a prime number greater than 1), the loop will complete and the counter will equal \(N - 1\>.
inputFormat
The input consists of a single integer \(N\) provided on one line. \(N\) can be any positive integer. In the edge case when \(N = 1\), note that the loop does not execute.
outputFormat
Output a single integer representing the number of iterations performed before an integer that divides \(N\) is found. For \(N = 1\), the output should be 0.
sample
6
3