function [Nout, Rout] = find_N_R(N, R)
% find Nout (approximately N) and R_out (approximately R), such that Nout
% is an integer and Nout/Rout is also an integer.
N1 = 0;
for jj = 1:100
    N = round(floor(N/R)*R);
    if N == N1
        N = N - 1;
    end
    R = N/round(N/R);
    N1 = N;
    if round(N) - N == 0 && round(N/R) - (N/R) == 0
        break;
    end
end
Nout = N;
Rout = R;
