How can I add every object, which is an NSNumber object to every other NSNumber object in the array and add the sum object to a new array?
e.g.
array1 has numbers 1, 2, and 3.
then do:
1 + 1 = 2 then add 2 to array2.
1 + 2 = 3 then add 3 to array2.
1 + 3 = 5 then add 4 to array2.
2 + 1 = 3 then add 3 to array2.
2 + 2 = 4 then add 4 to array2.
2 + 3 = 5 then add 5 to array2.
3 + 1 = 4 then add 4 to array2.
3 + 2 = 5 then add 5 to array2.
3 + 3 = 6 then add 6 to array2.
So array2 has 2, 3, 4, 3, 4, 5, 4, 5, 6.
I can handle the removal of the duplicates. I've tried putting a for loop within another for loop which would essentially do what I had outlined above but I have over 28,000 numbers which are not the numbers 1 - 28,000. It took over a very long time to compute since there are 28,000^2 possible sums. Surely there must be another way. Can anyone please elaborate?