The number 123456789 is concatenated 1729 times to form a number A
Similarly, the number 987654321 is concatenated 1729 times to form another number B
If A+B=C, find the sum of digits of C
5 open "conctsum.txt" for output as #2
10 N1=123456789
20 N2=987654321
30 for I=1 to 6
40 N1=N1*1000000000+123456789
50 N2=N2*1000000000+987654321
55 next
60 N3=N1+N2
70 print N1:print N2:print N3
80 print #2,N1:print #2,N2:print #2,N3
90 close #2
produces only 7 concatenations (actually 6 concatenations but producing 7 occurrences of the respective 9-digit sequences) rather than the 1729 asked for. But the result should be expandable reliably.
The 7*9=63 digit length of each summand produces a 64-digit sum, with 63 of those digits being a 1 and one being a zero.
In fact, spelled out, it's easy to see why:
123456789123456789123456789123456789123456789123456789123456789
987654321987654321987654321987654321987654321987654321987654321
1111111111111111111111111111111111111111111111111111111111111110
The sum of digits of this sum is just the length of each addend. In the case of what's mentioned, or presumably meant, is 9 * 1729 = 15,561.
|
Posted by Charlie
on 2019-05-15 11:23:30 |