function val = reciprocals_of_primes(n)
% val = reciprocals_of_primes(n)
%
% computes the reciprocals of all prime numbers from 1 through n.
% The entries for non-prime numbers are set to one.
%
% Input
% n : upper bound (assumed a positive integer)
%
% Output
% val : vector of length the reciprocals of the primes
% Loop over the integers from 1 through n and assign the reciprocals
% or 1, respectively, to the output vector.
for iNumber = 1:n
if (~isprime(iNumber))
val = 1;
else
val(iNumber) = 1 / i;
end
end