Dear all,(adsbygoogle = window.adsbygoogle || []).push({});

I have difficulty to solve this code which involves looping,

In [1] := m = 1; n = 1 ; A = -1 ; B = 5 ;

In [2] := m = 1; n = 3 ; A = 8 ; B = -2 ;

In [3] := m = 1; n = 5 ; A = 9 ; B = 7 ;

In [4] := m = 3; n = 1 ; A = -2 ; B = 8 ;

In [5] := m = 3; n = 3 ; A = 4 ; B = 3 ;

In [6] := m = 3; n = 5 ; A = 9 ; B = -1 ;

In [7] := m = 5; n = 1 ; A = 6 ; B = 9 ;

In [8] := m = 5; n = 3 ; A = 2 ; B = 1 ;

In [9] := m = 5; n = 5 ; A = 3 ; B = -7 ;

Method 1:

In [10] := qsolve := Module[{mat, A, B, m, n}, Table[mat = A + B, {m, 1, 5, 2}, {n, 1, 5, 2}]]

Method 2:

In [11] := qsolve := Module[{mat, A, B, m, n}, Clear[mat,A,B]; Do[mat = A + B; Print[mat], {m, 1, 5, 2}, {n, 1, 5, 2}]]

I have tried to use both method1 and method2 but still failed.

Iam expecting the answer to be {4,6,16},{6,7,8},{15,3,-4}

Please let me know how to fix this code.

Many thanks for any help.

**Physics Forums | Science Articles, Homework Help, Discussion**

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# Mathematica: looping using Module

Can you offer guidance or do you also need help?

Draft saved
Draft deleted

**Physics Forums | Science Articles, Homework Help, Discussion**