Abundant odd numbers
Abundant odd numbers is a draft programming task. It is not yet considered ready to be promoted as a complete task, for reasons that should be found in its talk page.
n is Nice number if it's sum of their factors is greater than n.
Ring
<lang ring>
- Project: Nice numbers
max = 25 nr = 0 m = 1 check = 0 index = 0 while true
nice(m) if check = 1 nr = nr + 1 ok if nr = max exit ok m = m + 1
end
func nice(n)
check = 0 nArray = [] for i = 1 to n - 1 if n % i = 0 add(nArray,i) ok next sum = 0 for p = 1 to len(nArray) sum = sum + nArray[p] next if sum > n check = 1 index = index + 1 showArray(n,nArray,sum,index) ok
func showArray(n,nArray,sum,index)
see string(index) + ". " + string(n) + " => " for m = 1 to len(nArray) if m < len(nArray) see string(nArray[m]) + " + " else see string(nArray[m]) + " = " + string(sum) + " > " + string(n) + nl ok next
</lang>
- Output:
1. 12 => 1 + 2 + 3 + 4 + 6 = 16 > 12 2. 18 => 1 + 2 + 3 + 6 + 9 = 21 > 18 3. 20 => 1 + 2 + 4 + 5 + 10 = 22 > 20 4. 24 => 1 + 2 + 3 + 4 + 6 + 8 + 12 = 36 > 24 5. 30 => 1 + 2 + 3 + 5 + 6 + 10 + 15 = 42 > 30 6. 36 => 1 + 2 + 3 + 4 + 6 + 9 + 12 + 18 = 55 > 36 7. 40 => 1 + 2 + 4 + 5 + 8 + 10 + 20 = 50 > 40 8. 42 => 1 + 2 + 3 + 6 + 7 + 14 + 21 = 54 > 42 9. 48 => 1 + 2 + 3 + 4 + 6 + 8 + 12 + 16 + 24 = 76 > 48 10. 54 => 1 + 2 + 3 + 6 + 9 + 18 + 27 = 66 > 54 11. 56 => 1 + 2 + 4 + 7 + 8 + 14 + 28 = 64 > 56 12. 60 => 1 + 2 + 3 + 4 + 5 + 6 + 10 + 12 + 15 + 20 + 30 = 108 > 60 13. 66 => 1 + 2 + 3 + 6 + 11 + 22 + 33 = 78 > 66 14. 70 => 1 + 2 + 5 + 7 + 10 + 14 + 35 = 74 > 70 15. 72 => 1 + 2 + 3 + 4 + 6 + 8 + 9 + 12 + 18 + 24 + 36 = 123 > 72 16. 78 => 1 + 2 + 3 + 6 + 13 + 26 + 39 = 90 > 78 17. 80 => 1 + 2 + 4 + 5 + 8 + 10 + 16 + 20 + 40 = 106 > 80 18. 84 => 1 + 2 + 3 + 4 + 6 + 7 + 12 + 14 + 21 + 28 + 42 = 140 > 84 19. 88 => 1 + 2 + 4 + 8 + 11 + 22 + 44 = 92 > 88 20. 90 => 1 + 2 + 3 + 5 + 6 + 9 + 10 + 15 + 18 + 30 + 45 = 144 > 90 21. 96 => 1 + 2 + 3 + 4 + 6 + 8 + 12 + 16 + 24 + 32 + 48 = 156 > 96 22. 100 => 1 + 2 + 4 + 5 + 10 + 20 + 25 + 50 = 117 > 100 23. 102 => 1 + 2 + 3 + 6 + 17 + 34 + 51 = 114 > 102 24. 104 => 1 + 2 + 4 + 8 + 13 + 26 + 52 = 106 > 104 25. 108 => 1 + 2 + 3 + 4 + 6 + 9 + 12 + 18 + 27 + 36 + 54 = 172 > 108