I am coding a problem from project euler and its problem 52.
I cant seem to go any further and i need help finishing up the problem and making it work on MATLAB.
Problem: It can be seen that the number, 125874, and its double, 251748, contain exactly the same digits, but in a different order.
Find the smallest positive integer, x, such that 2x, 3x, 4x, 5x, and 6x, contain the same digits.
My code: MAIN
int begin=1;bool found=false;int result=0; while(not(found)) begin= begin*10; for i = 0: begin*10/6 found=true; for j=2:6 out1 = permuted(i,j*i); if out1, found = false ; break , end end if found, result=i; break , end endendfunction out1 = permuted(x,y)% ??? int arr[] =[10];
temp = y;while (temp>0) arr(mod(temp,10)) + 1; temp = temp / 10; end temp = x;while(temp > 0) arr(mod(temp/10)) - 1; temp = temp / 10; end for i=0;10; if arr(i) ~= 0 out1 = false; end end out1=true; end
I dont know what else to do can comeone please help me finish the code to complete the problem.
Best Answer