f=@(N,A)sum(unique((z=(1:N)'.*A)(z<N))) f(50,2)f(10,[3,5])f(28,[4,2])f(19,[7,5])f(50,[2,3,5])
Standard input is empty
f = @(N, A) sum (unique ((z = 1:N' .* A) (z < N))) ans = 600 ans = 23 ans = 182 ans = 51 ans = 857
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!