Not only Swift question of course applies. Example of how to expand the formula:
Use nested loops. For example:
var sum = 0 for i in 1...3 { for j in 1...2 { sum += a[i][j] } }
Nicolas Chabanovsky♦
38.1k5454 gold marks222222 silver marks438438 bronze marks
VAndrJVAndrJ
13.5k11 golden mark1010 silver marks3131 bronze badge
|
since A and B do not depend on i and j, you can simply multiply all 4 and get the result. A B m * n
EvgenyEvgeny
one
Try to write more detailed answers.You can include sample code, explain the solution, provide links with a more detailed analysis of the problem, etc. - Athari