-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsearch8.m
More file actions
19 lines (17 loc) · 854 Bytes
/
search8.m
File metadata and controls
19 lines (17 loc) · 854 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
function[new_array]=search8(adjNum)
%number into array
%value = [1 3 4 6 7 8 9 5 6 4 2 5 6 2 4 4 4 8 8 8 8];
value = '73167176531330624919225119674426574742355349194934969835203127745063262395783180169848018694788518438586156078911294949545950173795833195285320880551112540698747158523863050715693290963295227443043557668966489504452445231617318564030987111217223831136222989342338030813533627661428280644448664523874930358907296290491560440772390713810515859307960866701724271218839987979087922749219016997208880937766572733300105336788122023542180975125454059475224352584907711670556013604839586446706324415722155397536...(line truncated)...
num = value - '0';
total = 0;
for i = 1:(length(num)-adjNum)
v = i+adjNum;
val = prod(num(1,i:v));
if val>total
total = val;
new_array = num(1,i:v);
end
end
new_array
total
end