Quote:
Originally Posted by x2495iiii
Yes it does. That's not the problem.
The problem is that the function's final bit of logic (if 1 == 2 == 3 etc.) doesn't work. You need to test out all the sums individually, not all at once.
There are two ways to do this. One is to have a series of nested if/else if statements which compare each sum individually. This is the hard, sloppy way.
The other is to do the following:
-use a number list that inserts the value of each sum at its end
-use two number variables, one set to the value of the first item in the list, the other set to zero
-use an if/else inside a for all in order loop to check each number in the list against the first number variable. If they match, increment the zero variable by 1
-at the end, check to see if the zero variable now equals 8. If so, all numbers match and the square is magic
Try the latter method first.
|
Number lists? Are you talking about arrays? If so I don't think I can use them as we haven't covered that yet : ( and don't think they are expected.
The way I did it seems to work but if you think it will return un - magic number squares then I will have to review the exercise. (Can't have that happening) lol