Same program I was asking for help on earlier. Got it to work just fine except for this part.
Here's the whole function.
The idea is to classify numbers as abundant, deficient, or perfect. However, I can't fin the flaw in my logic that is turning up every number I punch in (including a known perfect number like 6) as abundant.Code:// Returns single character char FindSum(int x) { int y, z, sum = 0; char Class; for (y=1; y<x && y % 1 == 0; y++) { z = x / y; if (x % y == 0) sum += z; } if (sum == x) Class = 'P'; else if (sum > x) Class = 'A'; else Class = 'D'; return Class; }
Can anyone help?