Divisible by 55 means divisible by both 11 and 5. The latter condition is true if and only if the number ends in 0 or 5. The former divisibility holds if the difference between the sum of the odd positions differs from the sum of the even numbers by a multiple of 11.
In 12378945560, the odd positions add up to 21 and the even positions add up to 29. The last position is already a zero, so the simplest way to add 8 to the odd positions is merely to change the initial 1 to a 9:
92378945560
A difference of zero is indeed a multiple of 11, as 0*11.
That's sufficient for the first task.
The second and third tasks are somewhat more daunting; some positions are capable of being changed either up or down to effect the difference-of-sums multiple-of-11, but some cannot, and in the case of changing two digits, one affects the other.
clc
orig='12378945560'
mod(str2num(orig),11)
ctOdd=0; ctEven=0;
for i=1:2:11
ctOdd=ctOdd+str2num(orig(i));
end
for i=2:2:10
ctEven=ctEven+str2num(orig(i));
end
disp([ctOdd ctEven])
ct=0;
for a=1:length(orig)
tst1=orig;
for i=0:9
if i~=str2num(orig(a))
tst1(a)=num2str(i);
tst=mod(str2num(tst1),11);
tst5=mod(str2num(tst1),5);
if tst==0 && tst5==0
fprintf('%2d %2d %12d\n',a,i,str2num(tst1))
ct=ct+1;
end
for b=a+1:length(tst1)
tst2=tst1;
for j=0:9
if j~=str2num(orig(b))
tst2(b)=num2str(j);
tst=mod(str2num(tst2),11);
tst5=mod(str2num(tst2),5);
if tst==0 && tst5==0
fprintf('%2d %2d %2d %2d %12d\n',a,i,b,j,str2num(tst2))
ct=ct+1;
end
end
end
end
end
end
end
disp(ct)
finds 346 such changes allow divisibility by 55.
(or 337 if you don't like a leading zero.)
I don't know why I tested for divisibility by 11 and 5 separately, except that's what I did when finding one manual solution.
orig =
'12378945560'
ans =
3 difference between odd and even totals, mod 11
21 29 odd and even totals
Explanation of the below table entries:
The 92378945560 found above is listed as
1 9 92378945560
representing position 1 changed to a 9, and showing the resulting number.
If two digits are changed, the result is shown for example by
1 2 4 0 22308945560
representing position 1 changed to a 2 and position 4 changed to a 0.
1 0 2 4 4378945560
1 0 3 1 2178945560
1 0 4 9 2398945560
1 0 5 6 2376945560
1 0 6 0 2378045560
1 0 7 2 2378925560
1 0 8 7 2378947560
1 0 9 3 2378945360
1 0 10 8 2378945580
1 2 2 6 26378945560
1 2 4 0 22308945560
1 2 5 4 22374945560
1 2 6 2 22378245560
1 2 7 0 22378905560
1 2 8 9 22378949560
1 2 9 1 22378945160
1 3 2 7 37378945560
1 3 3 9 32978945560
1 3 4 1 32318945560
1 3 5 3 32373945560
1 3 6 3 32378345560
1 3 9 0 32378945060
1 3 10 0 32378945500
1 4 2 8 48378945560
1 4 3 8 42878945560
1 4 4 2 42328945560
1 4 5 2 42372945560
1 4 6 4 42378445560
1 4 7 9 42378995560
1 4 8 0 42378940560
1 4 10 1 42378945510
1 4 11 5 42378945565
1 5 2 9 59378945560
1 5 3 7 52778945560
1 5 4 3 52338945560
1 5 5 1 52371945560
1 5 6 5 52378545560
1 5 7 8 52378985560
1 5 8 1 52378941560
1 5 9 9 52378945960
1 5 10 2 52378945520
1 6 3 6 62678945560
1 6 4 4 62348945560
1 6 5 0 62370945560
1 6 6 6 62378645560
1 6 7 7 62378975560
1 6 8 2 62378942560
1 6 9 8 62378945860
1 6 10 3 62378945530
1 7 2 0 70378945560
1 7 3 5 72578945560
1 7 4 5 72358945560
1 7 6 7 72378745560
1 7 7 6 72378965560
1 7 8 3 72378943560
1 7 9 7 72378945760
1 7 10 4 72378945540
1 8 2 1 81378945560
1 8 3 4 82478945560
1 8 4 6 82368945560
1 8 5 9 82379945560
1 8 6 8 82378845560
1 8 7 5 82378955560
1 8 8 4 82378944560
1 8 9 6 82378945660
1 8 10 5 82378945550
1 9 92378945560
2 0 3 9 10978945560
2 0 4 1 10318945560
2 0 5 3 10373945560
2 0 6 3 10378345560
2 0 9 0 10378945060
2 0 10 0 10378945500
2 1 4 0 11308945560
2 1 5 4 11374945560
2 1 6 2 11378245560
2 1 7 0 11378905560
2 1 8 9 11378949560
2 1 9 1 11378945160
2 3 3 1 13178945560
2 3 4 9 13398945560
2 3 5 6 13376945560
2 3 6 0 13378045560
2 3 7 2 13378925560
2 3 8 7 13378947560
2 3 9 3 13378945360
2 3 10 8 13378945580
2 4 3 2 14278945560
2 4 4 8 14388945560
2 4 5 7 14377945560
2 4 7 3 14378935560
2 4 8 6 14378946560
2 4 9 4 14378945460
2 4 10 7 14378945570
2 5 15378945560
2 6 3 4 16478945560
2 6 4 6 16368945560
2 6 5 9 16379945560
2 6 6 8 16378845560
2 6 7 5 16378955560
2 6 8 4 16378944560
2 6 9 6 16378945660
2 6 10 5 16378945550
2 7 3 5 17578945560
2 7 4 5 17358945560
2 7 6 7 17378745560
2 7 7 6 17378965560
2 7 8 3 17378943560
2 7 9 7 17378945760
2 7 10 4 17378945540
2 8 3 6 18678945560
2 8 4 4 18348945560
2 8 5 0 18370945560
2 8 6 6 18378645560
2 8 7 7 18378975560
2 8 8 2 18378942560
2 8 9 8 18378945860
2 8 10 3 18378945530
2 9 3 7 19778945560
2 9 4 3 19338945560
2 9 5 1 19371945560
2 9 6 5 19378545560
2 9 7 8 19378985560
2 9 8 1 19378941560
2 9 9 9 19378945960
2 9 10 2 19378945520
3 0 12078945560
3 1 4 8 12188945560
3 1 5 7 12177945560
3 1 7 3 12178935560
3 1 8 6 12178946560
3 1 9 4 12178945460
3 1 10 7 12178945570
3 2 4 9 12298945560
3 2 5 6 12276945560
3 2 6 0 12278045560
3 2 7 2 12278925560
3 2 8 7 12278947560
3 2 9 3 12278945360
3 2 10 8 12278945580
3 4 4 0 12408945560
3 4 5 4 12474945560
3 4 6 2 12478245560
3 4 7 0 12478905560
3 4 8 9 12478949560
3 4 9 1 12478945160
3 5 4 1 12518945560
3 5 5 3 12573945560
3 5 6 3 12578345560
3 5 9 0 12578945060
3 5 10 0 12578945500
3 6 4 2 12628945560
3 6 5 2 12672945560
3 6 6 4 12678445560
3 6 7 9 12678995560
3 6 8 0 12678940560
3 6 10 1 12678945510
3 6 11 5 12678945565
3 7 4 3 12738945560
3 7 5 1 12771945560
3 7 6 5 12778545560
3 7 7 8 12778985560
3 7 8 1 12778941560
3 7 9 9 12778945960
3 7 10 2 12778945520
3 8 4 4 12848945560
3 8 5 0 12870945560
3 8 6 6 12878645560
3 8 7 7 12878975560
3 8 8 2 12878942560
3 8 9 8 12878945860
3 8 10 3 12878945530
3 9 4 5 12958945560
3 9 6 7 12978745560
3 9 7 6 12978965560
3 9 8 3 12978943560
3 9 9 7 12978945760
3 9 10 4 12978945540
4 0 5 9 12309945560
4 0 6 8 12308845560
4 0 7 5 12308955560
4 0 8 4 12308944560
4 0 9 6 12308945660
4 0 10 5 12308945550
4 1 6 7 12318745560
4 1 7 6 12318965560
4 1 8 3 12318943560
4 1 9 7 12318945760
4 1 10 4 12318945540
4 2 5 0 12320945560
4 2 6 6 12328645560
4 2 7 7 12328975560
4 2 8 2 12328942560
4 2 9 8 12328945860
4 2 10 3 12328945530
4 3 5 1 12331945560
4 3 6 5 12338545560
4 3 7 8 12338985560
4 3 8 1 12338941560
4 3 9 9 12338945960
4 3 10 2 12338945520
4 4 5 2 12342945560
4 4 6 4 12348445560
4 4 7 9 12348995560
4 4 8 0 12348940560
4 4 10 1 12348945510
4 4 11 5 12348945565
4 5 5 3 12353945560
4 5 6 3 12358345560
4 5 9 0 12358945060
4 5 10 0 12358945500
4 6 5 4 12364945560
4 6 6 2 12368245560
4 6 7 0 12368905560
4 6 8 9 12368949560
4 6 9 1 12368945160
4 8 5 6 12386945560
4 8 6 0 12388045560
4 8 7 2 12388925560
4 8 8 7 12388947560
4 8 9 3 12388945360
4 8 10 8 12388945580
4 9 5 7 12397945560
4 9 7 3 12398935560
4 9 8 6 12398946560
4 9 9 4 12398945460
4 9 10 7 12398945570
5 0 6 4 12370445560
5 0 7 9 12370995560
5 0 8 0 12370940560
5 0 10 1 12370945510
5 0 11 5 12370945565
5 1 6 5 12371545560
5 1 7 8 12371985560
5 1 8 1 12371941560
5 1 9 9 12371945960
5 1 10 2 12371945520
5 2 6 6 12372645560
5 2 7 7 12372975560
5 2 8 2 12372942560
5 2 9 8 12372945860
5 2 10 3 12372945530
5 3 6 7 12373745560
5 3 7 6 12373965560
5 3 8 3 12373943560
5 3 9 7 12373945760
5 3 10 4 12373945540
5 4 6 8 12374845560
5 4 7 5 12374955560
5 4 8 4 12374944560
5 4 9 6 12374945660
5 4 10 5 12374945550
5 5 12375945560
5 6 7 3 12376935560
5 6 8 6 12376946560
5 6 9 4 12376945460
5 6 10 7 12376945570
5 7 6 0 12377045560
5 7 7 2 12377925560
5 7 8 7 12377947560
5 7 9 3 12377945360
5 7 10 8 12377945580
5 9 6 2 12379245560
5 9 7 0 12379905560
5 9 8 9 12379949560
5 9 9 1 12379945160
6 0 7 3 12378035560
6 0 8 6 12378046560
6 0 9 4 12378045460
6 0 10 7 12378045570
6 1 12378145560
6 2 7 5 12378255560
6 2 8 4 12378244560
6 2 9 6 12378245660
6 2 10 5 12378245550
6 3 7 6 12378365560
6 3 8 3 12378343560
6 3 9 7 12378345760
6 3 10 4 12378345540
6 4 7 7 12378475560
6 4 8 2 12378442560
6 4 9 8 12378445860
6 4 10 3 12378445530
6 5 7 8 12378585560
6 5 8 1 12378541560
6 5 9 9 12378545960
6 5 10 2 12378545520
6 6 7 9 12378695560
6 6 8 0 12378640560
6 6 10 1 12378645510
6 6 11 5 12378645565
6 7 9 0 12378745060
6 7 10 0 12378745500
6 8 7 0 12378805560
6 8 8 9 12378849560
6 8 9 1 12378845160
7 0 8 4 12378904560
7 0 9 6 12378905660
7 0 10 5 12378905550
7 1 12378915560
7 2 8 6 12378926560
7 2 9 4 12378925460
7 2 10 7 12378925570
7 3 8 7 12378937560
7 3 9 3 12378935360
7 3 10 8 12378935580
7 5 8 9 12378959560
7 5 9 1 12378955160
7 6 9 0 12378965060
7 6 10 0 12378965500
7 7 8 0 12378970560
7 7 10 1 12378975510
7 7 11 5 12378975565
7 8 8 1 12378981560
7 8 9 9 12378985960
7 8 10 2 12378985520
7 9 8 2 12378992560
7 9 9 8 12378995860
7 9 10 3 12378995530
8 0 9 8 12378940860
8 0 10 3 12378940530
8 1 9 9 12378941960
8 1 10 2 12378941520
8 2 10 1 12378942510
8 2 11 5 12378942565
8 3 9 0 12378943060
8 3 10 0 12378943500
8 4 9 1 12378944160
8 6 9 3 12378946360
8 6 10 8 12378946580
8 7 9 4 12378947460
8 7 10 7 12378947570
8 8 12378948560
8 9 9 6 12378949660
8 9 10 5 12378949550
9 0 10 4 12378945040
9 1 10 5 12378945150
9 2 12378945260
9 3 10 7 12378945370
9 4 10 8 12378945480
9 7 10 0 12378945700
9 8 10 1 12378945810
9 8 11 5 12378945865
9 9 10 2 12378945920
10 3 11 5 12378945535
10 9 12378945590
346
>>
|
Posted by Charlie
on 2021-02-08 10:17:20 |