The first 2 digits are the product of the first 2 numbers in the sum: 3*5=15. Then you multiply the first and last numbers: 3*7=21. Finally you add 15+21 and subtract the centre number: 15+21=36, 36-5=31. So if A+B+C=123040, then AB=12, AC=30, and B=42-40=2, so A=6, C=5. In the second version, instead of subtracting the 2nd number, you're adding the first: 3*7=21, 3*8=24, 21+24+3=48. So if D+E+F=303570, DE=30, DF=35, and 65+D=70, making D=5, E=6, F=7.