Skip to content

Instantly share code, notes, and snippets.

@hholst80
Created August 14, 2018 11:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hholst80/77614efd67ccd79ca7eea8dda738bc65 to your computer and use it in GitHub Desktop.
Save hholst80/77614efd67ccd79ca7eea8dda738bc65 to your computer and use it in GitHub Desktop.
summa produkt pussel
K = 100;
A = zeros(K);
B = zeros(K);
for x = 2:K
for y = 2:K
A(x,y) = x + y;
B(x,y) = x * y;
end
end
% Eliminate lower diagonal part of B
A = triu(A);
B = triu(B);
% Eliminate all unique numbers from B
% The way that Henrik Holst suggested doing it.
% for b = B(:)'
% if sum(B(:) == b) == 1
% B(B(:) == b) = 0;
% end
% end
% Eliminate all factors of two primes
% for i = 1:K*K
% if length(factor(B(i))) <= 2
% B(i) = 0;
% end
% end
% Eliminate all products divisible by a prime less than 541
% NOTE: This is all products.
% p = primes(541);
%
% for i = 1:K*K
% if any(ismember(factor(B(i)), p))
% B(i) = 0;
% end
% end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment