Abundant odd numbers
You are encouraged to solve this task according to the task description, using any language you may know.
An Abundant number is a number n for which the sum of divisors σ(n) > 2n,
or, equivalently, the sum of proper divisors (or aliquot sum) s(n) > n.
- E.G.
12 is abundant, it has the proper divisors 1,2,3,4 & 6 which sum to 16 ( > 12 or n);
or alternately, has the sigma sum of 1,2,3,4,6 & 12 which sum to 28 ( > 24 or 2n).
Abundant numbers are common, though even abundant numbers seem to be much more common than odd abundant numbers.
To make things more interesting, this task is specifically about finding odd abundant numbers.
- Task
- Find and display here: at least the first 25 abundant odd numbers and either their proper divisor sum or sigma sum.
- Find and display here: the one thousandth abundant odd number and either its proper divisor sum or sigma sum.
- Find and display here: the first abundant odd number greater than one billion (109) and either its proper divisor sum or sigma sum.
- Reference
American Journal of Mathematics, Vol. 35, No. 4 (Oct., 1913), pp. 413-422 - Finiteness of the Odd Perfect and Primitive Abundant Numbers with n Distinct Prime Factors (LE Dickson)
ALGOL 68
<lang algol68>BEGIN
# find some abundant odd numbers - numbers where the sum of the proper # # divisors is bigger than the number # # itself #
# returns the sum of the proper divisors of n # PROC divisor sum = ( INT n )INT: BEGIN INT sum := 1; FOR d FROM 2 TO ENTIER sqrt( n ) DO IF n MOD d = 0 THEN sum +:= d; IF INT other d := n OVER d; other d /= d THEN sum +:= other d FI FI OD; sum END # divisor sum # ; # find numbers required by the task # BEGIN # first 25 odd abundant numbers # INT odd number := 1; INT a count := 0; INT d sum := 0; print( ( "The first 25 abundant odd numbers:", newline ) ); WHILE a count < 25 DO IF ( d sum := divisor sum( odd number ) ) > odd number THEN a count +:= 1; print( ( whole( odd number, -6 ) , " proper divisor sum: " , whole( d sum, 0 ) , newline ) ) FI; odd number +:= 2 OD; # 1000th odd abundant number # WHILE a count < 1 000 DO IF ( d sum := divisor sum( odd number ) ) > odd number THEN a count := a count + 1 FI; odd number +:= 2 OD; print( ( "1000th abundant odd number:" , newline , " " , whole( odd number - 2, 0 ) , " proper divisor sum: " , whole( d sum, 0 ) , newline ) ); # first odd abundant number > one billion # odd number := 1 000 000 001; BOOL found := FALSE; WHILE NOT found DO IF ( d sum := divisor sum( odd number ) ) > odd number THEN found := TRUE; print( ( "First abundant odd number > 1 000 000 000:" , newline , " " , whole( odd number, 0 ) , " proper divisor sum: " , whole( d sum, 0 ) , newline ) ) FI; odd number +:= 2 OD END
END</lang>
- Output:
The first 25 abundant odd numbers: 945 proper divisor sum: 975 1575 proper divisor sum: 1649 2205 proper divisor sum: 2241 2835 proper divisor sum: 2973 3465 proper divisor sum: 4023 4095 proper divisor sum: 4641 4725 proper divisor sum: 5195 5355 proper divisor sum: 5877 5775 proper divisor sum: 6129 5985 proper divisor sum: 6495 6435 proper divisor sum: 6669 6615 proper divisor sum: 7065 6825 proper divisor sum: 7063 7245 proper divisor sum: 7731 7425 proper divisor sum: 7455 7875 proper divisor sum: 8349 8085 proper divisor sum: 8331 8415 proper divisor sum: 8433 8505 proper divisor sum: 8967 8925 proper divisor sum: 8931 9135 proper divisor sum: 9585 9555 proper divisor sum: 9597 9765 proper divisor sum: 10203 10395 proper divisor sum: 12645 11025 proper divisor sum: 11946 1000th abundant odd number: 492975 proper divisor sum: 519361 First abundant odd number > 1 000 000 000: 1000000575 proper divisor sum: 1083561009
BASIC256
<lang BASIC256> numimpar = 1 contar = 0 sumaDiv = 0
function SumaDivisores(n) # Devuelve la suma de los divisores propios de n suma = 1 i = int(sqr(n))
for d = 2 to i if n % d = 0 then suma += d otroD = n \ d if otroD <> d Then suma += otroD end if Next d Return suma End Function
- Encontrar los números requeridos por la tarea:
- primeros 25 números abundantes impares
Print "Los primeros 25 números impares abundantes:" While contar < 25 sumaDiv = SumaDivisores(numimpar) If sumaDiv > numimpar Then contar += 1 Print numimpar & " suma divisoria adecuada: " & sumaDiv End If numimpar += 2 End While
- 1000er número impar abundante
While contar < 1000 sumaDiv = SumaDivisores(numimpar) print sumaDiv & " " & contar If sumaDiv > numimpar Then contar += 1 numimpar += 2 End While Print Chr(10) & "1000º número impar abundante:" Print " " & (numimpar - 2) & " suma divisoria adecuada: " & sumaDiv
- primer número impar abundante > mil millones (millardo)
numimpar = 1000000001 encontrado = False While Not encontrado sumaDiv = SumaDivisores(numimpar) If sumaDiv > numimpar Then encontrado = True Print Chr(10) & "Primer número impar abundante > 1 000 000 000:" Print " " & numimpar & " suma divisoria adecuada: " & sumaDiv End If numimpar += 2 End While End </lang>
C++
<lang cpp>#include <algorithm>
- include <iostream>
- include <numeric>
- include <sstream>
- include <vector>
std::vector<int> divisors(int n) {
std::vector<int> divs{ 1 }; std::vector<int> divs2;
for (int i = 2; i*i <= n; i++) { if (n%i == 0) { int j = n / i; divs.push_back(i); if (i != j) { divs2.push_back(j); } } } std::copy(divs2.crbegin(), divs2.crend(), std::back_inserter(divs));
return divs;
}
int sum(const std::vector<int>& divs) {
return std::accumulate(divs.cbegin(), divs.cend(), 0);
}
std::string sumStr(const std::vector<int>& divs) {
auto it = divs.cbegin(); auto end = divs.cend(); std::stringstream ss;
if (it != end) { ss << *it; it = std::next(it); } while (it != end) { ss << " + " << *it; it = std::next(it); }
return ss.str();
}
int abundantOdd(int searchFrom, int countFrom, int countTo, bool printOne) {
int count = countFrom; int n = searchFrom; for (; count < countTo; n += 2) { auto divs = divisors(n); int tot = sum(divs); if (tot > n) { count++; if (printOne && count < countTo) { continue; } auto s = sumStr(divs); if (printOne) { printf("%d < %s = %d\n", n, s.c_str(), tot); } else { printf("%2d. %5d < %s = %d\n", count, n, s.c_str(), tot); } } } return n;
}
int main() {
using namespace std;
const int max = 25; cout << "The first " << max << " abundant odd primes are:\n"; int n = abundantOdd(1, 0, 25, false);
cout << "\nThe one thousandth abundant odd number is:\n"; abundantOdd(n, 25, 1000, true);
cout << "\nThe first abundant odd number above one billion is:\n"; abundantOdd(1e9 + 1, 0, 1, true);
return 0;
}</lang>
- Output:
The first 25 abundant odd primes are: 1. 945 < 1 + 3 + 5 + 7 + 9 + 15 + 21 + 27 + 35 + 45 + 63 + 105 + 135 + 189 + 315 = 975 2. 1575 < 1 + 3 + 5 + 7 + 9 + 15 + 21 + 25 + 35 + 45 + 63 + 75 + 105 + 175 + 225 + 315 + 525 = 1649 3. 2205 < 1 + 3 + 5 + 7 + 9 + 15 + 21 + 35 + 45 + 49 + 63 + 105 + 147 + 245 + 315 + 441 + 735 = 2241 4. 2835 < 1 + 3 + 5 + 7 + 9 + 15 + 21 + 27 + 35 + 45 + 63 + 81 + 105 + 135 + 189 + 315 + 405 + 567 + 945 = 2973 5. 3465 < 1 + 3 + 5 + 7 + 9 + 11 + 15 + 21 + 33 + 35 + 45 + 55 + 63 + 77 + 99 + 105 + 165 + 231 + 315 + 385 + 495 + 693 + 1155 = 4023 6. 4095 < 1 + 3 + 5 + 7 + 9 + 13 + 15 + 21 + 35 + 39 + 45 + 63 + 65 + 91 + 105 + 117 + 195 + 273 + 315 + 455 + 585 + 819 + 1365 = 4641 7. 4725 < 1 + 3 + 5 + 7 + 9 + 15 + 21 + 25 + 27 + 35 + 45 + 63 + 75 + 105 + 135 + 175 + 189 + 225 + 315 + 525 + 675 + 945 + 1575 = 5195 8. 5355 < 1 + 3 + 5 + 7 + 9 + 15 + 17 + 21 + 35 + 45 + 51 + 63 + 85 + 105 + 119 + 153 + 255 + 315 + 357 + 595 + 765 + 1071 + 1785 = 5877 9. 5775 < 1 + 3 + 5 + 7 + 11 + 15 + 21 + 25 + 33 + 35 + 55 + 75 + 77 + 105 + 165 + 175 + 231 + 275 + 385 + 525 + 825 + 1155 + 1925 = 6129 10. 5985 < 1 + 3 + 5 + 7 + 9 + 15 + 19 + 21 + 35 + 45 + 57 + 63 + 95 + 105 + 133 + 171 + 285 + 315 + 399 + 665 + 855 + 1197 + 1995 = 6495 11. 6435 < 1 + 3 + 5 + 9 + 11 + 13 + 15 + 33 + 39 + 45 + 55 + 65 + 99 + 117 + 143 + 165 + 195 + 429 + 495 + 585 + 715 + 1287 + 2145 = 6669 12. 6615 < 1 + 3 + 5 + 7 + 9 + 15 + 21 + 27 + 35 + 45 + 49 + 63 + 105 + 135 + 147 + 189 + 245 + 315 + 441 + 735 + 945 + 1323 + 2205 = 7065 13. 6825 < 1 + 3 + 5 + 7 + 13 + 15 + 21 + 25 + 35 + 39 + 65 + 75 + 91 + 105 + 175 + 195 + 273 + 325 + 455 + 525 + 975 + 1365 + 2275 = 7063 14. 7245 < 1 + 3 + 5 + 7 + 9 + 15 + 21 + 23 + 35 + 45 + 63 + 69 + 105 + 115 + 161 + 207 + 315 + 345 + 483 + 805 + 1035 + 1449 + 2415 = 7731 15. 7425 < 1 + 3 + 5 + 9 + 11 + 15 + 25 + 27 + 33 + 45 + 55 + 75 + 99 + 135 + 165 + 225 + 275 + 297 + 495 + 675 + 825 + 1485 + 2475 = 7455 16. 7875 < 1 + 3 + 5 + 7 + 9 + 15 + 21 + 25 + 35 + 45 + 63 + 75 + 105 + 125 + 175 + 225 + 315 + 375 + 525 + 875 + 1125 + 1575 + 2625 = 8349 17. 8085 < 1 + 3 + 5 + 7 + 11 + 15 + 21 + 33 + 35 + 49 + 55 + 77 + 105 + 147 + 165 + 231 + 245 + 385 + 539 + 735 + 1155 + 1617 + 2695 = 8331 18. 8415 < 1 + 3 + 5 + 9 + 11 + 15 + 17 + 33 + 45 + 51 + 55 + 85 + 99 + 153 + 165 + 187 + 255 + 495 + 561 + 765 + 935 + 1683 + 2805 = 8433 19. 8505 < 1 + 3 + 5 + 7 + 9 + 15 + 21 + 27 + 35 + 45 + 63 + 81 + 105 + 135 + 189 + 243 + 315 + 405 + 567 + 945 + 1215 + 1701 + 2835 = 8967 20. 8925 < 1 + 3 + 5 + 7 + 15 + 17 + 21 + 25 + 35 + 51 + 75 + 85 + 105 + 119 + 175 + 255 + 357 + 425 + 525 + 595 + 1275 + 1785 + 2975 = 8931 21. 9135 < 1 + 3 + 5 + 7 + 9 + 15 + 21 + 29 + 35 + 45 + 63 + 87 + 105 + 145 + 203 + 261 + 315 + 435 + 609 + 1015 + 1305 + 1827 + 3045 = 9585 22. 9555 < 1 + 3 + 5 + 7 + 13 + 15 + 21 + 35 + 39 + 49 + 65 + 91 + 105 + 147 + 195 + 245 + 273 + 455 + 637 + 735 + 1365 + 1911 + 3185 = 9597 23. 9765 < 1 + 3 + 5 + 7 + 9 + 15 + 21 + 31 + 35 + 45 + 63 + 93 + 105 + 155 + 217 + 279 + 315 + 465 + 651 + 1085 + 1395 + 1953 + 3255 = 10203 24. 10395 < 1 + 3 + 5 + 7 + 9 + 11 + 15 + 21 + 27 + 33 + 35 + 45 + 55 + 63 + 77 + 99 + 105 + 135 + 165 + 189 + 231 + 297 + 315 + 385 + 495 + 693 + 945 + 1155 + 1485 + 2079 + 3465 = 12645 25. 11025 < 1 + 3 + 5 + 7 + 9 + 15 + 21 + 25 + 35 + 45 + 49 + 63 + 75 + 105 + 147 + 175 + 225 + 245 + 315 + 441 + 525 + 735 + 1225 + 1575 + 2205 + 3675 = 11946 The one thousandth abundant odd number is: 492975 < 1 + 3 + 5 + 7 + 9 + 15 + 21 + 25 + 35 + 45 + 63 + 75 + 105 + 175 + 225 + 313 + 315 + 525 + 939 + 1565 + 1575 + 2191 + 2817 + 4695 + 6573 + 7825 + 10955 + 14085 + 19719 + 23475 + 32865 + 54775 + 70425 + 98595 + 164325 = 519361 The first abundant odd number above one billion is: 1000000575 < 1 + 3 + 5 + 7 + 9 + 15 + 21 + 25 + 35 + 45 + 49 + 63 + 75 + 105 + 147 + 175 + 225 + 245 + 315 + 441 + 525 + 735 + 1225 + 1575 + 2205 + 3675 + 11025 + 90703 + 272109 + 453515 + 634921 + 816327 + 1360545 + 1904763 + 2267575 + 3174605 + 4081635 + 4444447 + 5714289 + 6802725 + 9523815 + 13333341 + 15873025 + 20408175 + 22222235 + 28571445 + 40000023 + 47619075 + 66666705 + 111111175 + 142857225 + 200000115 + 333333525 = 1083561009
D
<lang d>import std.stdio;
int[] divisors(int n) {
import std.range;
int[] divs = [1]; int[] divs2;
for (int i = 2; i * i <= n; i++) { if (n % i == 0) { int j = n / i; divs ~= i; if (i != j) { divs2 ~= j; } } } divs ~= retro(divs2).array;
return divs;
}
int abundantOdd(int searchFrom, int countFrom, int countTo, bool printOne) {
import std.algorithm.iteration; import std.array; import std.conv;
int count = countFrom; int n = searchFrom; for (; count < countTo; n += 2) { auto divs = divisors(n); int tot = sum(divs); if (tot > n) { count++; if (printOne && count < countTo) { continue; } auto s = divs.map!(to!string).join(" + "); if (printOne) { writefln("%d < %s = %d", n, s, tot); } else { writefln("%2d. %5d < %s = %d", count, n, s, tot); } } } return n;
}
void main() {
const int max = 25; writefln("The first %d abundant odd primes are:", max); int n = abundantOdd(1, 0, 25, false);
writeln("\nThe one thousandth abundant odd number is:"); abundantOdd(n, 25, 1000, true);
writeln("\nThe first abundant odd number above one billion is:"); abundantOdd(cast(int)(1e9 + 1), 0, 1, true);
}</lang>
- Output:
The first 25 abundant odd primes are: 1. 945 < 1 + 3 + 5 + 7 + 9 + 15 + 21 + 27 + 35 + 45 + 63 + 105 + 135 + 189 + 315 = 975 2. 1575 < 1 + 3 + 5 + 7 + 9 + 15 + 21 + 25 + 35 + 45 + 63 + 75 + 105 + 175 + 225 + 315 + 525 = 1649 3. 2205 < 1 + 3 + 5 + 7 + 9 + 15 + 21 + 35 + 45 + 49 + 63 + 105 + 147 + 245 + 315 + 441 + 735 = 2241 4. 2835 < 1 + 3 + 5 + 7 + 9 + 15 + 21 + 27 + 35 + 45 + 63 + 81 + 105 + 135 + 189 + 315 + 405 + 567 + 945 = 2973 5. 3465 < 1 + 3 + 5 + 7 + 9 + 11 + 15 + 21 + 33 + 35 + 45 + 55 + 63 + 77 + 99 + 105 + 165 + 231 + 315 + 385 + 495 + 693 + 1155 = 4023 6. 4095 < 1 + 3 + 5 + 7 + 9 + 13 + 15 + 21 + 35 + 39 + 45 + 63 + 65 + 91 + 105 + 117 + 195 + 273 + 315 + 455 + 585 + 819 + 1365 = 4641 7. 4725 < 1 + 3 + 5 + 7 + 9 + 15 + 21 + 25 + 27 + 35 + 45 + 63 + 75 + 105 + 135 + 175 + 189 + 225 + 315 + 525 + 675 + 945 + 1575 = 5195 8. 5355 < 1 + 3 + 5 + 7 + 9 + 15 + 17 + 21 + 35 + 45 + 51 + 63 + 85 + 105 + 119 + 153 + 255 + 315 + 357 + 595 + 765 + 1071 + 1785 = 5877 9. 5775 < 1 + 3 + 5 + 7 + 11 + 15 + 21 + 25 + 33 + 35 + 55 + 75 + 77 + 105 + 165 + 175 + 231 + 275 + 385 + 525 + 825 + 1155 + 1925 = 6129 10. 5985 < 1 + 3 + 5 + 7 + 9 + 15 + 19 + 21 + 35 + 45 + 57 + 63 + 95 + 105 + 133 + 171 + 285 + 315 + 399 + 665 + 855 + 1197 + 1995 = 6495 11. 6435 < 1 + 3 + 5 + 9 + 11 + 13 + 15 + 33 + 39 + 45 + 55 + 65 + 99 + 117 + 143 + 165 + 195 + 429 + 495 + 585 + 715 + 1287 + 2145 = 6669 12. 6615 < 1 + 3 + 5 + 7 + 9 + 15 + 21 + 27 + 35 + 45 + 49 + 63 + 105 + 135 + 147 + 189 + 245 + 315 + 441 + 735 + 945 + 1323 + 2205 = 7065 13. 6825 < 1 + 3 + 5 + 7 + 13 + 15 + 21 + 25 + 35 + 39 + 65 + 75 + 91 + 105 + 175 + 195 + 273 + 325 + 455 + 525 + 975 + 1365 + 2275 = 7063 14. 7245 < 1 + 3 + 5 + 7 + 9 + 15 + 21 + 23 + 35 + 45 + 63 + 69 + 105 + 115 + 161 + 207 + 315 + 345 + 483 + 805 + 1035 + 1449 + 2415 = 7731 15. 7425 < 1 + 3 + 5 + 9 + 11 + 15 + 25 + 27 + 33 + 45 + 55 + 75 + 99 + 135 + 165 + 225 + 275 + 297 + 495 + 675 + 825 + 1485 + 2475 = 7455 16. 7875 < 1 + 3 + 5 + 7 + 9 + 15 + 21 + 25 + 35 + 45 + 63 + 75 + 105 + 125 + 175 + 225 + 315 + 375 + 525 + 875 + 1125 + 1575 + 2625 = 8349 17. 8085 < 1 + 3 + 5 + 7 + 11 + 15 + 21 + 33 + 35 + 49 + 55 + 77 + 105 + 147 + 165 + 231 + 245 + 385 + 539 + 735 + 1155 + 1617 + 2695 = 8331 18. 8415 < 1 + 3 + 5 + 9 + 11 + 15 + 17 + 33 + 45 + 51 + 55 + 85 + 99 + 153 + 165 + 187 + 255 + 495 + 561 + 765 + 935 + 1683 + 2805 = 8433 19. 8505 < 1 + 3 + 5 + 7 + 9 + 15 + 21 + 27 + 35 + 45 + 63 + 81 + 105 + 135 + 189 + 243 + 315 + 405 + 567 + 945 + 1215 + 1701 + 2835 = 8967 20. 8925 < 1 + 3 + 5 + 7 + 15 + 17 + 21 + 25 + 35 + 51 + 75 + 85 + 105 + 119 + 175 + 255 + 357 + 425 + 525 + 595 + 1275 + 1785 + 2975 = 8931 21. 9135 < 1 + 3 + 5 + 7 + 9 + 15 + 21 + 29 + 35 + 45 + 63 + 87 + 105 + 145 + 203 + 261 + 315 + 435 + 609 + 1015 + 1305 + 1827 + 3045 = 9585 22. 9555 < 1 + 3 + 5 + 7 + 13 + 15 + 21 + 35 + 39 + 49 + 65 + 91 + 105 + 147 + 195 + 245 + 273 + 455 + 637 + 735 + 1365 + 1911 + 3185 = 9597 23. 9765 < 1 + 3 + 5 + 7 + 9 + 15 + 21 + 31 + 35 + 45 + 63 + 93 + 105 + 155 + 217 + 279 + 315 + 465 + 651 + 1085 + 1395 + 1953 + 3255 = 10203 24. 10395 < 1 + 3 + 5 + 7 + 9 + 11 + 15 + 21 + 27 + 33 + 35 + 45 + 55 + 63 + 77 + 99 + 105 + 135 + 165 + 189 + 231 + 297 + 315 + 385 + 495 + 693 + 945 + 1155 + 1485 + 2079 + 3465 = 12645 25. 11025 < 1 + 3 + 5 + 7 + 9 + 15 + 21 + 25 + 35 + 45 + 49 + 63 + 75 + 105 + 147 + 175 + 225 + 245 + 315 + 441 + 525 + 735 + 1225 + 1575 + 2205 + 3675 = 11946 The one thousandth abundant odd number is: 492975 < 1 + 3 + 5 + 7 + 9 + 15 + 21 + 25 + 35 + 45 + 63 + 75 + 105 + 175 + 225 + 313 + 315 + 525 + 939 + 1565 + 1575 + 2191 + 2817 + 4695 + 6573 + 7825 + 10955 + 14085 + 19719 + 23475 + 32865 + 54775 + 70425 + 98595 + 164325 = 519361 The first abundant odd number above one billion is: 1000000575 < 1 + 3 + 5 + 7 + 9 + 15 + 21 + 25 + 35 + 45 + 49 + 63 + 75 + 105 + 147 + 175 + 225 + 245 + 315 + 441 + 525 + 735 + 1225 + 1575 + 2205 + 3675 + 11025 + 90703 + 272109 + 453515 + 634921 + 816327 + 1360545 + 1904763 + 2267575 + 3174605 + 4081635 + 4444447 + 5714289 + 6802725 + 9523815 + 13333341 + 15873025 + 20408175 + 22222235 + 28571445 + 40000023 + 47619075 + 66666705 + 111111175 + 142857225 + 200000115 + 333333525 = 1083561009
Factor
<lang factor>USING: arrays formatting io kernel lists lists.lazy math math.primes.factors sequences tools.memory.private ; IN: rosetta-code.abundant-odd-numbers
- σ ( n -- sum ) divisors sum ;
- abundant? ( n -- ? ) [ σ ] [ 2 * ] bi > ;
- abundant-odds-from ( n -- list )
dup even? [ 1 + ] when [ 2 + ] lfrom-by [ abundant? ] lfilter ;
- first25 ( -- seq ) 25 1 abundant-odds-from ltake list>array ;
- 1,000th ( -- n ) 1 abundant-odds-from 999 [ cdr ] times car ;
- first>10^9 ( -- n ) 1,000,000,001 abundant-odds-from car ;
GENERIC: show ( obj -- ) M: integer show dup σ [ commas ] bi@ "%-6s σ = %s\n" printf ; M: array show [ show ] each ;
- abundant-odd-numbers-demo ( -- )
first25 "First 25 abundant odd numbers:" 1,000th "1,000th abundant odd number:" first>10^9 "First abundant odd number > one billion:" [ print show nl ] 2tri@ ;
MAIN: abundant-odd-numbers-demo</lang>
- Output:
First 25 abundant odd numbers: 945 σ = 1,920 1,575 σ = 3,224 2,205 σ = 4,446 2,835 σ = 5,808 3,465 σ = 7,488 4,095 σ = 8,736 4,725 σ = 9,920 5,355 σ = 11,232 5,775 σ = 11,904 5,985 σ = 12,480 6,435 σ = 13,104 6,615 σ = 13,680 6,825 σ = 13,888 7,245 σ = 14,976 7,425 σ = 14,880 7,875 σ = 16,224 8,085 σ = 16,416 8,415 σ = 16,848 8,505 σ = 17,472 8,925 σ = 17,856 9,135 σ = 18,720 9,555 σ = 19,152 9,765 σ = 19,968 10,395 σ = 23,040 11,025 σ = 22,971 1,000th abundant odd number: 492,975 σ = 1,012,336 First abundant odd number > one billion: 1,000,000,575 σ = 2,083,561,584
FreeBASIC
<lang freebasic> Declare Function SumaDivisores(n As Integer) As Integer
Dim numimpar As Integer = 1 Dim contar As Integer = 0 Dim sumaDiv As Integer = 0
Function SumaDivisores(n As Integer) As Integer
' Devuelve la suma de los divisores propios de n Dim suma As Integer = 1 Dim As Integer d, otroD For d = 2 To Cint(Sqr(n)) If n Mod d = 0 Then suma += d otroD = n \ d If otroD <> d Then suma += otroD End If Next d Return suma
End Function
' Encontrar los números requeridos por la tarea:
' primeros 25 números abundantes impares Print "Los primeros 25 números impares abundantes:" Do While contar < 25
sumaDiv = SumaDivisores(numimpar) If sumaDiv > numimpar Then contar += 1 Print using "######"; numimpar; Print " suma divisoria adecuada: " & sumaDiv End If numimpar += 2
Loop
' 1000er número impar abundante Do While contar < 1000
sumaDiv = SumaDivisores(numimpar) If sumaDiv > numimpar Then contar += 1 numimpar += 2
Loop Print Chr(10) & "1000º número impar abundante:" Print " " & (numimpar - 2) & " suma divisoria adecuada: " & sumaDiv
' primer número impar abundante > mil millones (millardo) numimpar = 1000000001 Dim encontrado As Boolean = False Do While Not encontrado
sumaDiv = SumaDivisores(numimpar) If sumaDiv > numimpar Then encontrado = True Print Chr(10) & "Primer número impar abundante > 1 000 000 000:" Print " " & numimpar & " suma divisoria adecuada: " & sumaDiv End If numimpar += 2
Loop End </lang>
- Output:
Los primeros 25 números impares abundantes: 945 suma divisoria adecuada: 975 1575 suma divisoria adecuada: 1649 2205 suma divisoria adecuada: 2241 2835 suma divisoria adecuada: 2973 3465 suma divisoria adecuada: 4023 4095 suma divisoria adecuada: 4641 4725 suma divisoria adecuada: 5195 5355 suma divisoria adecuada: 5877 5775 suma divisoria adecuada: 6129 5985 suma divisoria adecuada: 6495 6435 suma divisoria adecuada: 6669 6615 suma divisoria adecuada: 7065 6825 suma divisoria adecuada: 7063 7245 suma divisoria adecuada: 7731 7425 suma divisoria adecuada: 7455 7875 suma divisoria adecuada: 8349 8085 suma divisoria adecuada: 8331 8415 suma divisoria adecuada: 8433 8505 suma divisoria adecuada: 8967 8925 suma divisoria adecuada: 8931 9135 suma divisoria adecuada: 9585 9555 suma divisoria adecuada: 9597 9765 suma divisoria adecuada: 10203 10395 suma divisoria adecuada: 12645 11025 suma divisoria adecuada: 11946 1000º número impar abundante: 492975 suma divisoria adecuada: 519361 Primer número impar abundante > 1 000 000 000: 1000000575 suma divisoria adecuada: 1083561009
Go
<lang go>package main
import (
"fmt" "strconv"
)
func divisors(n int) []int {
divs := []int{1} divs2 := []int{} for i := 2; i*i <= n; i++ { if n%i == 0 { j := n / i divs = append(divs, i) if i != j { divs2 = append(divs2, j) } } } for i := len(divs2) - 1; i >= 0; i-- { divs = append(divs, divs2[i]) } return divs
}
func sum(divs []int) int {
tot := 0 for _, div := range divs { tot += div } return tot
}
func sumStr(divs []int) string {
s := "" for _, div := range divs { s += strconv.Itoa(div) + " + " } return s[0 : len(s)-3]
}
func abundantOdd(searchFrom, countFrom, countTo int, printOne bool) int {
count := countFrom n := searchFrom for ; count < countTo; n += 2 { divs := divisors(n) if tot := sum(divs); tot > n { count++ if printOne && count < countTo { continue } s := sumStr(divs) if !printOne { fmt.Printf("%2d. %5d < %s = %d\n", count, n, s, tot) } else { fmt.Printf("%d < %s = %d\n", n, s, tot) } } } return n
}
func main() {
const max = 25 fmt.Println("The first", max, "abundant odd numbers are:") n := abundantOdd(1, 0, 25, false)
fmt.Println("\nThe one thousandth abundant odd number is:") abundantOdd(n, 25, 1000, true)
fmt.Println("\nThe first abundant odd number above one billion is:") abundantOdd(1e9+1, 0, 1, true)
}</lang>
- Output:
The first 25 abundant odd numbers are: 1. 945 < 1 + 3 + 5 + 7 + 9 + 15 + 21 + 27 + 35 + 45 + 63 + 105 + 135 + 189 + 315 = 975 2. 1575 < 1 + 3 + 5 + 7 + 9 + 15 + 21 + 25 + 35 + 45 + 63 + 75 + 105 + 175 + 225 + 315 + 525 = 1649 3. 2205 < 1 + 3 + 5 + 7 + 9 + 15 + 21 + 35 + 45 + 49 + 63 + 105 + 147 + 245 + 315 + 441 + 735 = 2241 4. 2835 < 1 + 3 + 5 + 7 + 9 + 15 + 21 + 27 + 35 + 45 + 63 + 81 + 105 + 135 + 189 + 315 + 405 + 567 + 945 = 2973 5. 3465 < 1 + 3 + 5 + 7 + 9 + 11 + 15 + 21 + 33 + 35 + 45 + 55 + 63 + 77 + 99 + 105 + 165 + 231 + 315 + 385 + 495 + 693 + 1155 = 4023 6. 4095 < 1 + 3 + 5 + 7 + 9 + 13 + 15 + 21 + 35 + 39 + 45 + 63 + 65 + 91 + 105 + 117 + 195 + 273 + 315 + 455 + 585 + 819 + 1365 = 4641 7. 4725 < 1 + 3 + 5 + 7 + 9 + 15 + 21 + 25 + 27 + 35 + 45 + 63 + 75 + 105 + 135 + 175 + 189 + 225 + 315 + 525 + 675 + 945 + 1575 = 5195 8. 5355 < 1 + 3 + 5 + 7 + 9 + 15 + 17 + 21 + 35 + 45 + 51 + 63 + 85 + 105 + 119 + 153 + 255 + 315 + 357 + 595 + 765 + 1071 + 1785 = 5877 9. 5775 < 1 + 3 + 5 + 7 + 11 + 15 + 21 + 25 + 33 + 35 + 55 + 75 + 77 + 105 + 165 + 175 + 231 + 275 + 385 + 525 + 825 + 1155 + 1925 = 6129 10. 5985 < 1 + 3 + 5 + 7 + 9 + 15 + 19 + 21 + 35 + 45 + 57 + 63 + 95 + 105 + 133 + 171 + 285 + 315 + 399 + 665 + 855 + 1197 + 1995 = 6495 11. 6435 < 1 + 3 + 5 + 9 + 11 + 13 + 15 + 33 + 39 + 45 + 55 + 65 + 99 + 117 + 143 + 165 + 195 + 429 + 495 + 585 + 715 + 1287 + 2145 = 6669 12. 6615 < 1 + 3 + 5 + 7 + 9 + 15 + 21 + 27 + 35 + 45 + 49 + 63 + 105 + 135 + 147 + 189 + 245 + 315 + 441 + 735 + 945 + 1323 + 2205 = 7065 13. 6825 < 1 + 3 + 5 + 7 + 13 + 15 + 21 + 25 + 35 + 39 + 65 + 75 + 91 + 105 + 175 + 195 + 273 + 325 + 455 + 525 + 975 + 1365 + 2275 = 7063 14. 7245 < 1 + 3 + 5 + 7 + 9 + 15 + 21 + 23 + 35 + 45 + 63 + 69 + 105 + 115 + 161 + 207 + 315 + 345 + 483 + 805 + 1035 + 1449 + 2415 = 7731 15. 7425 < 1 + 3 + 5 + 9 + 11 + 15 + 25 + 27 + 33 + 45 + 55 + 75 + 99 + 135 + 165 + 225 + 275 + 297 + 495 + 675 + 825 + 1485 + 2475 = 7455 16. 7875 < 1 + 3 + 5 + 7 + 9 + 15 + 21 + 25 + 35 + 45 + 63 + 75 + 105 + 125 + 175 + 225 + 315 + 375 + 525 + 875 + 1125 + 1575 + 2625 = 8349 17. 8085 < 1 + 3 + 5 + 7 + 11 + 15 + 21 + 33 + 35 + 49 + 55 + 77 + 105 + 147 + 165 + 231 + 245 + 385 + 539 + 735 + 1155 + 1617 + 2695 = 8331 18. 8415 < 1 + 3 + 5 + 9 + 11 + 15 + 17 + 33 + 45 + 51 + 55 + 85 + 99 + 153 + 165 + 187 + 255 + 495 + 561 + 765 + 935 + 1683 + 2805 = 8433 19. 8505 < 1 + 3 + 5 + 7 + 9 + 15 + 21 + 27 + 35 + 45 + 63 + 81 + 105 + 135 + 189 + 243 + 315 + 405 + 567 + 945 + 1215 + 1701 + 2835 = 8967 20. 8925 < 1 + 3 + 5 + 7 + 15 + 17 + 21 + 25 + 35 + 51 + 75 + 85 + 105 + 119 + 175 + 255 + 357 + 425 + 525 + 595 + 1275 + 1785 + 2975 = 8931 21. 9135 < 1 + 3 + 5 + 7 + 9 + 15 + 21 + 29 + 35 + 45 + 63 + 87 + 105 + 145 + 203 + 261 + 315 + 435 + 609 + 1015 + 1305 + 1827 + 3045 = 9585 22. 9555 < 1 + 3 + 5 + 7 + 13 + 15 + 21 + 35 + 39 + 49 + 65 + 91 + 105 + 147 + 195 + 245 + 273 + 455 + 637 + 735 + 1365 + 1911 + 3185 = 9597 23. 9765 < 1 + 3 + 5 + 7 + 9 + 15 + 21 + 31 + 35 + 45 + 63 + 93 + 105 + 155 + 217 + 279 + 315 + 465 + 651 + 1085 + 1395 + 1953 + 3255 = 10203 24. 10395 < 1 + 3 + 5 + 7 + 9 + 11 + 15 + 21 + 27 + 33 + 35 + 45 + 55 + 63 + 77 + 99 + 105 + 135 + 165 + 189 + 231 + 297 + 315 + 385 + 495 + 693 + 945 + 1155 + 1485 + 2079 + 3465 = 12645 25. 11025 < 1 + 3 + 5 + 7 + 9 + 15 + 21 + 25 + 35 + 45 + 49 + 63 + 75 + 105 + 147 + 175 + 225 + 245 + 315 + 441 + 525 + 735 + 1225 + 1575 + 2205 + 3675 = 11946 The one thousandth abundant odd number is: 492975 < 1 + 3 + 5 + 7 + 9 + 15 + 21 + 25 + 35 + 45 + 63 + 75 + 105 + 175 + 225 + 313 + 315 + 525 + 939 + 1565 + 1575 + 2191 + 2817 + 4695 + 6573 + 7825 + 10955 + 14085 + 19719 + 23475 + 32865 + 54775 + 70425 + 98595 + 164325 = 519361 The first abundant odd number above one billion is: 1000000575 < 1 + 3 + 5 + 7 + 9 + 15 + 21 + 25 + 35 + 45 + 49 + 63 + 75 + 105 + 147 + 175 + 225 + 245 + 315 + 441 + 525 + 735 + 1225 + 1575 + 2205 + 3675 + 11025 + 90703 + 272109 + 453515 + 634921 + 816327 + 1360545 + 1904763 + 2267575 + 3174605 + 4081635 + 4444447 + 5714289 + 6802725 + 9523815 + 13333341 + 15873025 + 20408175 + 22222235 + 28571445 + 40000023 + 47619075 + 66666705 + 111111175 + 142857225 + 200000115 + 333333525 = 1083561009
J
NB. https://www.math.upenn.edu/~deturck/m170/wk3/lecture/sumdiv.html s=: ([: */ [: ((<:@:(^ >:)/) % <:@:{.) __&q:)&> assert 6045 -: s 1800 aliquot_sum=: -~ s abundant=: < aliquot_sum Filter=: (#~`)(`:6) A=: abundant Filter 1 2 p. i. 260000 NB. a batch of abundant odd numbers # A NB. more than 1000, it's enough. 1054 NB. the first odd abundant numbers (,: aliquot_sum) 26 {. A 945 1575 2205 2835 3465 4095 4725 5355 5775 5985 6435 6615 6825 7245 7425 7875 8085 8415 8505 8925 9135 9555 9765 10395 11025 11655 975 1649 2241 2973 4023 4641 5195 5877 6129 6495 6669 7065 7063 7731 7455 8349 8331 8433 8967 8931 9585 9597 10203 12645 11946 12057 NB. the one thousandth abundant odd number (,: aliquot_sum) 999 { A 492975 519361 k=: adverb def '1000 * m' 1x k k k 1000000000 abundant Filter (1x k k k) + 1 2x p. i. 10x k 1000000575 1000001475 1000001625 1000001835 1000002465 1000003095 1000003725 1000004355 1000004775 1000004985 1000005435 1000005615 1000005825 1000006245 1000006425 1000006875 1000007505 1000008765 1000009395 1000010025 1000010655 1000011285 1000011705 100... (,: aliquot_sum) {. abundant Filter (1x k k k) + 1 2x p. i. 10x k 1000000575 1083561009
Julia
<lang julia>using Primes
function propfact(n)
f = [one(n)] for (p, x) in factor(n) f = reduce(vcat, [f*p^i for i in 1:x], init=f) end pop!(f) f
end
isabundant(n) = sum(propfact(n)) > n prettyprintfactors(n) = (a = propfact(n); println("$n has proper divisors $a, these sum to $(sum(a))."))
function oddabundantsfrom(startingint, needed, nprint=0)
n = isodd(startingint) ? startingint : startingint + 1 count = 0 while count < needed if isabundant(n) if nprint == 0 prettyprintfactors(n) elseif nprint == count + 1 prettyprintfactors(n) break end count += 1 end n += 2 end
end
println("First 25 abundant odd numbers:") oddabundantsfrom(2, 25)
println("The thousandth abundant odd number:") oddabundantsfrom(2, 1001, 1000)
println("The first abundant odd number greater than one billion:") oddabundantsfrom(1000000000, 1)
</lang>
- Output:
First 25 abundant odd numbers: 945 has proper divisors [1, 3, 9, 27, 5, 15, 45, 135, 7, 21, 63, 189, 35, 105, 315], these sum to 975. 1575 has proper divisors [1, 3, 9, 5, 15, 45, 25, 75, 225, 7, 21, 63, 35, 105, 315, 175, 525], these sum to 1649. 2205 has proper divisors [1, 3, 9, 5, 15, 45, 7, 21, 63, 35, 105, 315, 49, 147, 441, 245, 735], these sum to 2241. 2835 has proper divisors [1, 3, 9, 27, 81, 5, 15, 45, 135, 405, 7, 21, 63, 189, 567, 35, 105, 315, 945], these sum to 2973. 3465 has proper divisors [1, 3, 9, 5, 15, 45, 7, 21, 63, 35, 105, 315, 11, 33, 99, 55, 165, 495, 77, 231, 693, 385, 1155], these sum to 4023. 4095 has proper divisors [1, 3, 9, 5, 15, 45, 7, 21, 63, 35, 105, 315, 13, 39, 117, 65, 195, 585, 91, 273, 819, 455, 1365], these sum to 4641. 4725 has proper divisors [1, 3, 9, 27, 5, 15, 45, 135, 25, 75, 225, 675, 7, 21, 63, 189, 35, 105, 315, 945, 175, 525, 1575], these sum to 5195. 5355 has proper divisors [1, 3, 9, 5, 15, 45, 7, 21, 63, 35, 105, 315, 17, 51, 153, 85, 255, 765, 119, 357, 1071, 595, 1785], these sum to 5877. 5775 has proper divisors [1, 3, 5, 15, 25, 75, 7, 21, 35, 105, 175, 525, 11, 33, 55, 165, 275, 825, 77, 231, 385, 1155, 1925], these sum to 6129. 5985 has proper divisors [1, 3, 9, 5, 15, 45, 7, 21, 63, 35, 105, 315, 19, 57, 171, 95, 285, 855, 133, 399, 1197, 665, 1995], these sum to 6495. 6435 has proper divisors [1, 3, 9, 5, 15, 45, 11, 33, 99, 55, 165, 495, 13, 39, 117, 65, 195, 585, 143, 429, 1287, 715, 2145], these sum to 6669. 6615 has proper divisors [1, 3, 9, 27, 5, 15, 45, 135, 7, 21, 63, 189, 35, 105, 315, 945, 49, 147, 441, 1323, 245, 735, 2205], these sum to 7065. 6825 has proper divisors [1, 3, 5, 15, 25, 75, 7, 21, 35, 105, 175, 525, 13, 39, 65, 195, 325, 975, 91, 273, 455, 1365, 2275], these sum to 7063. 7245 has proper divisors [1, 3, 9, 5, 15, 45, 7, 21, 63, 35, 105, 315, 23, 69, 207, 115, 345, 1035, 161, 483, 1449, 805, 2415], these sum to 7731. 7425 has proper divisors [1, 3, 9, 27, 5, 15, 45, 135, 25, 75, 225, 675, 11, 33, 99, 297, 55, 165, 495, 1485, 275, 825, 2475], these sum to 7455. 7875 has proper divisors [1, 3, 9, 5, 15, 45, 25, 75, 225, 125, 375, 1125, 7, 21, 63, 35, 105, 315, 175, 525, 1575, 875, 2625], these sum to 8349. 8085 has proper divisors [1, 3, 5, 15, 7, 21, 35, 105, 49, 147, 245, 735, 11, 33, 55, 165, 77, 231, 385, 1155, 539, 1617, 2695], these sum to 8331. 8415 has proper divisors [1, 3, 9, 5, 15, 45, 11, 33, 99, 55, 165, 495, 17, 51, 153, 85, 255, 765, 187, 561, 1683, 935, 2805], these sum to 8433. 8505 has proper divisors [1, 3, 9, 27, 81, 243, 5, 15, 45, 135, 405, 1215, 7, 21, 63, 189, 567, 1701, 35, 105, 315, 945, 2835], these sum to 8967. 8925 has proper divisors [1, 3, 5, 15, 25, 75, 7, 21, 35, 105, 175, 525, 17, 51, 85, 255, 425, 1275, 119, 357, 595, 1785, 2975], these sum to 8931. 9135 has proper divisors [1, 3, 9, 5, 15, 45, 7, 21, 63, 35, 105, 315, 29, 87, 261, 145, 435, 1305, 203, 609, 1827, 1015, 3045], these sum to 9585. 9555 has proper divisors [1, 3, 5, 15, 7, 21, 35, 105, 49, 147, 245, 735, 13, 39, 65, 195, 91, 273, 455, 1365, 637, 1911, 3185], these sum to 9597. 9765 has proper divisors [1, 3, 9, 5, 15, 45, 7, 21, 63, 35, 105, 315, 31, 93, 279, 155, 465, 1395, 217, 651, 1953, 1085, 3255], these sum to 10203. 10395 has proper divisors [1, 3, 9, 27, 5, 15, 45, 135, 7, 21, 63, 189, 35, 105, 315, 945, 11, 33, 99, 297, 55, 165, 495, 1485, 77, 231, 693, 2079, 385, 1155, 3465], these sum to 12645. 11025 has proper divisors [1, 3, 9, 5, 15, 45, 25, 75, 225, 7, 21, 63, 35, 105, 315, 175, 525, 1575, 49, 147, 441, 245, 735, 2205, 1225, 3675], these sum to 11946. The thousandth abundant odd number: 492975 has proper divisors [1, 3, 9, 5, 15, 45, 25, 75, 225, 7, 21, 63, 35, 105, 315, 175, 525, 1575, 313, 939, 2817, 1565, 4695, 14085, 7825, 23475, 70425, 2191, 6573, 19719, 10955, 32865, 98595, 54775, 164325], these sum to 519361. The first abundant odd number greater than one billion: 1000000575 has proper divisors [1, 3, 9, 5, 15, 45, 25, 75, 225, 7, 21, 63, 35, 105, 315, 175, 525, 1575, 49, 147, 441, 245, 735, 2205, 1225, 3675, 11025, 90703, 272109, 816327, 453515, 1360545, 4081635, 2267575, 6802725, 20408175, 634921, 1904763, 5714289, 3174605, 9523815, 28571445, 15873025, 47619075, 142857225, 4444447, 13333341, 40000023, 22222235, 66666705, 200000115, 111111175, 333333525], these sum to 1083561009.
Kotlin
<lang scala>fun divisors(n: Int): List<Int> {
val divs = mutableListOf(1) val divs2 = mutableListOf<Int>()
var i = 2 while (i * i <= n) { if (n % i == 0) { val j = n / i divs.add(i) if (i != j) { divs2.add(j) } } i++ }
divs.addAll(divs2.reversed())
return divs
}
fun abundantOdd(searchFrom: Int, countFrom: Int, countTo: Int, printOne: Boolean): Int {
var count = countFrom var n = searchFrom
while (count < countTo) { val divs = divisors(n) val tot = divs.sum() if (tot > n) { count++ if (!printOne || count >= countTo) { val s = divs.joinToString(" + ") if (printOne) { println("$n < $s = $tot") } else { println("%2d. %5d < %s = %d".format(count, n, s, tot)) } } }
n += 2 }
return n
}
fun main() {
val max = 25 println("The first $max abundant primes are:") val n = abundantOdd(1, 0, 25, false)
println("\nThe one thousandth abundant odd number is:") abundantOdd(n, 25, 1000, true)
println("\nThe first abundant odd number above one billion is:") abundantOdd((1e9 + 1).toInt(), 0, 1, true)
}</lang>
- Output:
The first 25 abundant primes are: 1. 945 < 1 + 3 + 5 + 7 + 9 + 15 + 21 + 27 + 35 + 45 + 63 + 105 + 135 + 189 + 315 = 975 2. 1575 < 1 + 3 + 5 + 7 + 9 + 15 + 21 + 25 + 35 + 45 + 63 + 75 + 105 + 175 + 225 + 315 + 525 = 1649 3. 2205 < 1 + 3 + 5 + 7 + 9 + 15 + 21 + 35 + 45 + 49 + 63 + 105 + 147 + 245 + 315 + 441 + 735 = 2241 4. 2835 < 1 + 3 + 5 + 7 + 9 + 15 + 21 + 27 + 35 + 45 + 63 + 81 + 105 + 135 + 189 + 315 + 405 + 567 + 945 = 2973 5. 3465 < 1 + 3 + 5 + 7 + 9 + 11 + 15 + 21 + 33 + 35 + 45 + 55 + 63 + 77 + 99 + 105 + 165 + 231 + 315 + 385 + 495 + 693 + 1155 = 4023 6. 4095 < 1 + 3 + 5 + 7 + 9 + 13 + 15 + 21 + 35 + 39 + 45 + 63 + 65 + 91 + 105 + 117 + 195 + 273 + 315 + 455 + 585 + 819 + 1365 = 4641 7. 4725 < 1 + 3 + 5 + 7 + 9 + 15 + 21 + 25 + 27 + 35 + 45 + 63 + 75 + 105 + 135 + 175 + 189 + 225 + 315 + 525 + 675 + 945 + 1575 = 5195 8. 5355 < 1 + 3 + 5 + 7 + 9 + 15 + 17 + 21 + 35 + 45 + 51 + 63 + 85 + 105 + 119 + 153 + 255 + 315 + 357 + 595 + 765 + 1071 + 1785 = 5877 9. 5775 < 1 + 3 + 5 + 7 + 11 + 15 + 21 + 25 + 33 + 35 + 55 + 75 + 77 + 105 + 165 + 175 + 231 + 275 + 385 + 525 + 825 + 1155 + 1925 = 6129 10. 5985 < 1 + 3 + 5 + 7 + 9 + 15 + 19 + 21 + 35 + 45 + 57 + 63 + 95 + 105 + 133 + 171 + 285 + 315 + 399 + 665 + 855 + 1197 + 1995 = 6495 11. 6435 < 1 + 3 + 5 + 9 + 11 + 13 + 15 + 33 + 39 + 45 + 55 + 65 + 99 + 117 + 143 + 165 + 195 + 429 + 495 + 585 + 715 + 1287 + 2145 = 6669 12. 6615 < 1 + 3 + 5 + 7 + 9 + 15 + 21 + 27 + 35 + 45 + 49 + 63 + 105 + 135 + 147 + 189 + 245 + 315 + 441 + 735 + 945 + 1323 + 2205 = 7065 13. 6825 < 1 + 3 + 5 + 7 + 13 + 15 + 21 + 25 + 35 + 39 + 65 + 75 + 91 + 105 + 175 + 195 + 273 + 325 + 455 + 525 + 975 + 1365 + 2275 = 7063 14. 7245 < 1 + 3 + 5 + 7 + 9 + 15 + 21 + 23 + 35 + 45 + 63 + 69 + 105 + 115 + 161 + 207 + 315 + 345 + 483 + 805 + 1035 + 1449 + 2415 = 7731 15. 7425 < 1 + 3 + 5 + 9 + 11 + 15 + 25 + 27 + 33 + 45 + 55 + 75 + 99 + 135 + 165 + 225 + 275 + 297 + 495 + 675 + 825 + 1485 + 2475 = 7455 16. 7875 < 1 + 3 + 5 + 7 + 9 + 15 + 21 + 25 + 35 + 45 + 63 + 75 + 105 + 125 + 175 + 225 + 315 + 375 + 525 + 875 + 1125 + 1575 + 2625 = 8349 17. 8085 < 1 + 3 + 5 + 7 + 11 + 15 + 21 + 33 + 35 + 49 + 55 + 77 + 105 + 147 + 165 + 231 + 245 + 385 + 539 + 735 + 1155 + 1617 + 2695 = 8331 18. 8415 < 1 + 3 + 5 + 9 + 11 + 15 + 17 + 33 + 45 + 51 + 55 + 85 + 99 + 153 + 165 + 187 + 255 + 495 + 561 + 765 + 935 + 1683 + 2805 = 8433 19. 8505 < 1 + 3 + 5 + 7 + 9 + 15 + 21 + 27 + 35 + 45 + 63 + 81 + 105 + 135 + 189 + 243 + 315 + 405 + 567 + 945 + 1215 + 1701 + 2835 = 8967 20. 8925 < 1 + 3 + 5 + 7 + 15 + 17 + 21 + 25 + 35 + 51 + 75 + 85 + 105 + 119 + 175 + 255 + 357 + 425 + 525 + 595 + 1275 + 1785 + 2975 = 8931 21. 9135 < 1 + 3 + 5 + 7 + 9 + 15 + 21 + 29 + 35 + 45 + 63 + 87 + 105 + 145 + 203 + 261 + 315 + 435 + 609 + 1015 + 1305 + 1827 + 3045 = 9585 22. 9555 < 1 + 3 + 5 + 7 + 13 + 15 + 21 + 35 + 39 + 49 + 65 + 91 + 105 + 147 + 195 + 245 + 273 + 455 + 637 + 735 + 1365 + 1911 + 3185 = 9597 23. 9765 < 1 + 3 + 5 + 7 + 9 + 15 + 21 + 31 + 35 + 45 + 63 + 93 + 105 + 155 + 217 + 279 + 315 + 465 + 651 + 1085 + 1395 + 1953 + 3255 = 10203 24. 10395 < 1 + 3 + 5 + 7 + 9 + 11 + 15 + 21 + 27 + 33 + 35 + 45 + 55 + 63 + 77 + 99 + 105 + 135 + 165 + 189 + 231 + 297 + 315 + 385 + 495 + 693 + 945 + 1155 + 1485 + 2079 + 3465 = 12645 25. 11025 < 1 + 3 + 5 + 7 + 9 + 15 + 21 + 25 + 35 + 45 + 49 + 63 + 75 + 105 + 147 + 175 + 225 + 245 + 315 + 441 + 525 + 735 + 1225 + 1575 + 2205 + 3675 = 11946 The one thousandth abundant odd number is: 492975 < 1 + 3 + 5 + 7 + 9 + 15 + 21 + 25 + 35 + 45 + 63 + 75 + 105 + 175 + 225 + 313 + 315 + 525 + 939 + 1565 + 1575 + 2191 + 2817 + 4695 + 6573 + 7825 + 10955 + 14085 + 19719 + 23475 + 32865 + 54775 + 70425 + 98595 + 164325 = 519361 The first abundant odd number above one billion is: 1000000575 < 1 + 3 + 5 + 7 + 9 + 15 + 21 + 25 + 35 + 45 + 49 + 63 + 75 + 105 + 147 + 175 + 225 + 245 + 315 + 441 + 525 + 735 + 1225 + 1575 + 2205 + 3675 + 11025 + 90703 + 272109 + 453515 + 634921 + 816327 + 1360545 + 1904763 + 2267575 + 3174605 + 4081635 + 4444447 + 5714289 + 6802725 + 9523815 + 13333341 + 15873025 + 20408175 + 22222235 + 28571445 + 40000023 + 47619075 + 66666705 + 111111175 + 142857225 + 200000115 + 333333525 = 1083561009
Perl
<lang perl>use strict; use warnings; use feature 'say'; use ntheory qw/divisor_sum divisors/;
sub odd_abundants {
my($start,$count) = @_; my $n = int(( $start + 2 ) / 3); $n += 1 if 0 == $n / 2; $n *= 3; my @out; while (@out < $count) { $n += 6; next unless (my $ds = divisor_sum($n)) > 2*$n; my @d = divisors($n); push @out, sprintf "%6d: divisor sum: %s = %d", $n, join(' + ', @d[0..@d-2]), $ds-$n; } @out;
}
say 'First 25 abundant odd numbers:'; say for odd_abundants(1, 25); say "\nOne thousandth abundant odd number:\n", (odd_abundants(1, 1000))[999]; say "\nFirst abundant odd number above one billion:\n", odd_abundants(999_999_999, 1);</lang>
- Output:
First 25 abundant odd numbers: 945: divisor sum: 1 + 3 + 5 + 7 + 9 + 15 + 21 + 27 + 35 + 45 + 63 + 105 + 135 + 189 + 315 = 975 1575: divisor sum: 1 + 3 + 5 + 7 + 9 + 15 + 21 + 25 + 35 + 45 + 63 + 75 + 105 + 175 + 225 + 315 + 525 = 1649 2205: divisor sum: 1 + 3 + 5 + 7 + 9 + 15 + 21 + 35 + 45 + 49 + 63 + 105 + 147 + 245 + 315 + 441 + 735 = 2241 2835: divisor sum: 1 + 3 + 5 + 7 + 9 + 15 + 21 + 27 + 35 + 45 + 63 + 81 + 105 + 135 + 189 + 315 + 405 + 567 + 945 = 2973 3465: divisor sum: 1 + 3 + 5 + 7 + 9 + 11 + 15 + 21 + 33 + 35 + 45 + 55 + 63 + 77 + 99 + 105 + 165 + 231 + 315 + 385 + 495 + 693 + 1155 = 4023 4095: divisor sum: 1 + 3 + 5 + 7 + 9 + 13 + 15 + 21 + 35 + 39 + 45 + 63 + 65 + 91 + 105 + 117 + 195 + 273 + 315 + 455 + 585 + 819 + 1365 = 4641 4725: divisor sum: 1 + 3 + 5 + 7 + 9 + 15 + 21 + 25 + 27 + 35 + 45 + 63 + 75 + 105 + 135 + 175 + 189 + 225 + 315 + 525 + 675 + 945 + 1575 = 5195 5355: divisor sum: 1 + 3 + 5 + 7 + 9 + 15 + 17 + 21 + 35 + 45 + 51 + 63 + 85 + 105 + 119 + 153 + 255 + 315 + 357 + 595 + 765 + 1071 + 1785 = 5877 5775: divisor sum: 1 + 3 + 5 + 7 + 11 + 15 + 21 + 25 + 33 + 35 + 55 + 75 + 77 + 105 + 165 + 175 + 231 + 275 + 385 + 525 + 825 + 1155 + 1925 = 6129 5985: divisor sum: 1 + 3 + 5 + 7 + 9 + 15 + 19 + 21 + 35 + 45 + 57 + 63 + 95 + 105 + 133 + 171 + 285 + 315 + 399 + 665 + 855 + 1197 + 1995 = 6495 6435: divisor sum: 1 + 3 + 5 + 9 + 11 + 13 + 15 + 33 + 39 + 45 + 55 + 65 + 99 + 117 + 143 + 165 + 195 + 429 + 495 + 585 + 715 + 1287 + 2145 = 6669 6615: divisor sum: 1 + 3 + 5 + 7 + 9 + 15 + 21 + 27 + 35 + 45 + 49 + 63 + 105 + 135 + 147 + 189 + 245 + 315 + 441 + 735 + 945 + 1323 + 2205 = 7065 6825: divisor sum: 1 + 3 + 5 + 7 + 13 + 15 + 21 + 25 + 35 + 39 + 65 + 75 + 91 + 105 + 175 + 195 + 273 + 325 + 455 + 525 + 975 + 1365 + 2275 = 7063 7245: divisor sum: 1 + 3 + 5 + 7 + 9 + 15 + 21 + 23 + 35 + 45 + 63 + 69 + 105 + 115 + 161 + 207 + 315 + 345 + 483 + 805 + 1035 + 1449 + 2415 = 7731 7425: divisor sum: 1 + 3 + 5 + 9 + 11 + 15 + 25 + 27 + 33 + 45 + 55 + 75 + 99 + 135 + 165 + 225 + 275 + 297 + 495 + 675 + 825 + 1485 + 2475 = 7455 7875: divisor sum: 1 + 3 + 5 + 7 + 9 + 15 + 21 + 25 + 35 + 45 + 63 + 75 + 105 + 125 + 175 + 225 + 315 + 375 + 525 + 875 + 1125 + 1575 + 2625 = 8349 8085: divisor sum: 1 + 3 + 5 + 7 + 11 + 15 + 21 + 33 + 35 + 49 + 55 + 77 + 105 + 147 + 165 + 231 + 245 + 385 + 539 + 735 + 1155 + 1617 + 2695 = 8331 8415: divisor sum: 1 + 3 + 5 + 9 + 11 + 15 + 17 + 33 + 45 + 51 + 55 + 85 + 99 + 153 + 165 + 187 + 255 + 495 + 561 + 765 + 935 + 1683 + 2805 = 8433 8505: divisor sum: 1 + 3 + 5 + 7 + 9 + 15 + 21 + 27 + 35 + 45 + 63 + 81 + 105 + 135 + 189 + 243 + 315 + 405 + 567 + 945 + 1215 + 1701 + 2835 = 8967 8925: divisor sum: 1 + 3 + 5 + 7 + 15 + 17 + 21 + 25 + 35 + 51 + 75 + 85 + 105 + 119 + 175 + 255 + 357 + 425 + 525 + 595 + 1275 + 1785 + 2975 = 8931 9135: divisor sum: 1 + 3 + 5 + 7 + 9 + 15 + 21 + 29 + 35 + 45 + 63 + 87 + 105 + 145 + 203 + 261 + 315 + 435 + 609 + 1015 + 1305 + 1827 + 3045 = 9585 9555: divisor sum: 1 + 3 + 5 + 7 + 13 + 15 + 21 + 35 + 39 + 49 + 65 + 91 + 105 + 147 + 195 + 245 + 273 + 455 + 637 + 735 + 1365 + 1911 + 3185 = 9597 9765: divisor sum: 1 + 3 + 5 + 7 + 9 + 15 + 21 + 31 + 35 + 45 + 63 + 93 + 105 + 155 + 217 + 279 + 315 + 465 + 651 + 1085 + 1395 + 1953 + 3255 = 10203 10395: divisor sum: 1 + 3 + 5 + 7 + 9 + 11 + 15 + 21 + 27 + 33 + 35 + 45 + 55 + 63 + 77 + 99 + 105 + 135 + 165 + 189 + 231 + 297 + 315 + 385 + 495 + 693 + 945 + 1155 + 1485 + 2079 + 3465 = 12645 11025: divisor sum: 1 + 3 + 5 + 7 + 9 + 15 + 21 + 25 + 35 + 45 + 49 + 63 + 75 + 105 + 147 + 175 + 225 + 245 + 315 + 441 + 525 + 735 + 1225 + 1575 + 2205 + 3675 = 11946 One thousandth abundant odd number: 492975: divisor sum: 1 + 3 + 5 + 7 + 9 + 15 + 21 + 25 + 35 + 45 + 63 + 75 + 105 + 175 + 225 + 313 + 315 + 525 + 939 + 1565 + 1575 + 2191 + 2817 + 4695 + 6573 + 7825 + 10955 + 14085 + 19719 + 23475 + 32865 + 54775 + 70425 + 98595 + 164325 = 519361 First abundant odd number above one billion: 1000000575: divisor sum: 1 + 3 + 5 + 7 + 9 + 15 + 21 + 25 + 35 + 45 + 49 + 63 + 75 + 105 + 147 + 175 + 225 + 245 + 315 + 441 + 525 + 735 + 1225 + 1575 + 2205 + 3675 + 11025 + 90703 + 272109 + 453515 + 634921 + 816327 + 1360545 + 1904763 + 2267575 + 3174605 + 4081635 + 4444447 + 5714289 + 6802725 + 9523815 + 13333341 + 15873025 + 20408175 + 22222235 + 28571445 + 40000023 + 47619075 + 66666705 + 111111175 + 142857225 + 200000115 + 333333525 = 1083561009
Perl 6
<lang perl6>sub odd-abundant (\x) {
my @l = x.is-prime ?? 1 !! flat 1, (3 .. x.sqrt.floor).map: -> \d { next unless d +& 1; my \y = x div d; next if y * d !== x; d !== y ?? (d, y) !! d }; @l.sum > x ?? @l.sort !! Empty;
}
sub odd-abundants (Int :$start-at is copy) {
$start-at = ( $start-at + 2 ) div 3; $start-at += $start-at %% 2; $start-at *= 3; ($start-at, *+6 ... *).hyper.map: { next unless my $oa = .&odd-abundant; sprintf "%6d: divisor sum: {$oa.join: ' + '} = {$oa.sum}", $_ }
}
put 'First 25 abundant odd numbers:'; .put for odd-abundants( :start-at(1) )[^25];
put "\nOne thousandth abundant odd number:\n" ~ odd-abundants( :start-at(1) )[999] ~
"\n\nFirst abundant odd number above one billion:\n" ~ odd-abundants( :start-at(1_000_000_000) ).head;</lang>
- Output:
First 25 abundant odd numbers: 945: divisor sum: 1 + 3 + 5 + 7 + 9 + 15 + 21 + 27 + 35 + 45 + 63 + 105 + 135 + 189 + 315 = 975 1575: divisor sum: 1 + 3 + 5 + 7 + 9 + 15 + 21 + 25 + 35 + 45 + 63 + 75 + 105 + 175 + 225 + 315 + 525 = 1649 2205: divisor sum: 1 + 3 + 5 + 7 + 9 + 15 + 21 + 35 + 45 + 49 + 63 + 105 + 147 + 245 + 315 + 441 + 735 = 2241 2835: divisor sum: 1 + 3 + 5 + 7 + 9 + 15 + 21 + 27 + 35 + 45 + 63 + 81 + 105 + 135 + 189 + 315 + 405 + 567 + 945 = 2973 3465: divisor sum: 1 + 3 + 5 + 7 + 9 + 11 + 15 + 21 + 33 + 35 + 45 + 55 + 63 + 77 + 99 + 105 + 165 + 231 + 315 + 385 + 495 + 693 + 1155 = 4023 4095: divisor sum: 1 + 3 + 5 + 7 + 9 + 13 + 15 + 21 + 35 + 39 + 45 + 63 + 65 + 91 + 105 + 117 + 195 + 273 + 315 + 455 + 585 + 819 + 1365 = 4641 4725: divisor sum: 1 + 3 + 5 + 7 + 9 + 15 + 21 + 25 + 27 + 35 + 45 + 63 + 75 + 105 + 135 + 175 + 189 + 225 + 315 + 525 + 675 + 945 + 1575 = 5195 5355: divisor sum: 1 + 3 + 5 + 7 + 9 + 15 + 17 + 21 + 35 + 45 + 51 + 63 + 85 + 105 + 119 + 153 + 255 + 315 + 357 + 595 + 765 + 1071 + 1785 = 5877 5775: divisor sum: 1 + 3 + 5 + 7 + 11 + 15 + 21 + 25 + 33 + 35 + 55 + 75 + 77 + 105 + 165 + 175 + 231 + 275 + 385 + 525 + 825 + 1155 + 1925 = 6129 5985: divisor sum: 1 + 3 + 5 + 7 + 9 + 15 + 19 + 21 + 35 + 45 + 57 + 63 + 95 + 105 + 133 + 171 + 285 + 315 + 399 + 665 + 855 + 1197 + 1995 = 6495 6435: divisor sum: 1 + 3 + 5 + 9 + 11 + 13 + 15 + 33 + 39 + 45 + 55 + 65 + 99 + 117 + 143 + 165 + 195 + 429 + 495 + 585 + 715 + 1287 + 2145 = 6669 6615: divisor sum: 1 + 3 + 5 + 7 + 9 + 15 + 21 + 27 + 35 + 45 + 49 + 63 + 105 + 135 + 147 + 189 + 245 + 315 + 441 + 735 + 945 + 1323 + 2205 = 7065 6825: divisor sum: 1 + 3 + 5 + 7 + 13 + 15 + 21 + 25 + 35 + 39 + 65 + 75 + 91 + 105 + 175 + 195 + 273 + 325 + 455 + 525 + 975 + 1365 + 2275 = 7063 7245: divisor sum: 1 + 3 + 5 + 7 + 9 + 15 + 21 + 23 + 35 + 45 + 63 + 69 + 105 + 115 + 161 + 207 + 315 + 345 + 483 + 805 + 1035 + 1449 + 2415 = 7731 7425: divisor sum: 1 + 3 + 5 + 9 + 11 + 15 + 25 + 27 + 33 + 45 + 55 + 75 + 99 + 135 + 165 + 225 + 275 + 297 + 495 + 675 + 825 + 1485 + 2475 = 7455 7875: divisor sum: 1 + 3 + 5 + 7 + 9 + 15 + 21 + 25 + 35 + 45 + 63 + 75 + 105 + 125 + 175 + 225 + 315 + 375 + 525 + 875 + 1125 + 1575 + 2625 = 8349 8085: divisor sum: 1 + 3 + 5 + 7 + 11 + 15 + 21 + 33 + 35 + 49 + 55 + 77 + 105 + 147 + 165 + 231 + 245 + 385 + 539 + 735 + 1155 + 1617 + 2695 = 8331 8415: divisor sum: 1 + 3 + 5 + 9 + 11 + 15 + 17 + 33 + 45 + 51 + 55 + 85 + 99 + 153 + 165 + 187 + 255 + 495 + 561 + 765 + 935 + 1683 + 2805 = 8433 8505: divisor sum: 1 + 3 + 5 + 7 + 9 + 15 + 21 + 27 + 35 + 45 + 63 + 81 + 105 + 135 + 189 + 243 + 315 + 405 + 567 + 945 + 1215 + 1701 + 2835 = 8967 8925: divisor sum: 1 + 3 + 5 + 7 + 15 + 17 + 21 + 25 + 35 + 51 + 75 + 85 + 105 + 119 + 175 + 255 + 357 + 425 + 525 + 595 + 1275 + 1785 + 2975 = 8931 9135: divisor sum: 1 + 3 + 5 + 7 + 9 + 15 + 21 + 29 + 35 + 45 + 63 + 87 + 105 + 145 + 203 + 261 + 315 + 435 + 609 + 1015 + 1305 + 1827 + 3045 = 9585 9555: divisor sum: 1 + 3 + 5 + 7 + 13 + 15 + 21 + 35 + 39 + 49 + 65 + 91 + 105 + 147 + 195 + 245 + 273 + 455 + 637 + 735 + 1365 + 1911 + 3185 = 9597 9765: divisor sum: 1 + 3 + 5 + 7 + 9 + 15 + 21 + 31 + 35 + 45 + 63 + 93 + 105 + 155 + 217 + 279 + 315 + 465 + 651 + 1085 + 1395 + 1953 + 3255 = 10203 10395: divisor sum: 1 + 3 + 5 + 7 + 9 + 11 + 15 + 21 + 27 + 33 + 35 + 45 + 55 + 63 + 77 + 99 + 105 + 135 + 165 + 189 + 231 + 297 + 315 + 385 + 495 + 693 + 945 + 1155 + 1485 + 2079 + 3465 = 12645 11025: divisor sum: 1 + 3 + 5 + 7 + 9 + 15 + 21 + 25 + 35 + 45 + 49 + 63 + 75 + 105 + 147 + 175 + 225 + 245 + 315 + 441 + 525 + 735 + 1225 + 1575 + 2205 + 3675 = 11946 One thousandth abundant odd number: 492975: divisor sum: 1 + 3 + 5 + 7 + 9 + 15 + 21 + 25 + 35 + 45 + 63 + 75 + 105 + 175 + 225 + 313 + 315 + 525 + 939 + 1565 + 1575 + 2191 + 2817 + 4695 + 6573 + 7825 + 10955 + 14085 + 19719 + 23475 + 32865 + 54775 + 70425 + 98595 + 164325 = 519361 First abundant odd number above one billion: 1000000575: divisor sum: 1 + 3 + 5 + 7 + 9 + 15 + 21 + 25 + 35 + 45 + 49 + 63 + 75 + 105 + 147 + 175 + 225 + 245 + 315 + 441 + 525 + 735 + 1225 + 1575 + 2205 + 3675 + 11025 + 90703 + 272109 + 453515 + 634921 + 816327 + 1360545 + 1904763 + 2267575 + 3174605 + 4081635 + 4444447 + 5714289 + 6802725 + 9523815 + 13333341 + 15873025 + 20408175 + 22222235 + 28571445 + 40000023 + 47619075 + 66666705 + 111111175 + 142857225 + 200000115 + 333333525 = 1083561009
Phix
<lang Phix>function abundantOdd(integer n, done, lim, bool printAll)
while done<lim do atom tot = sum(factors(n,-1)) if tot>n then done += 1 if printAll or done=lim then string ln = iff(printAll?sprintf("%2d. ",done):"") printf(1,"%s%,6d (proper sum:%,d)\n",{ln,n,tot}) end if end if n += 2 end while printf(1,"\n") return n
end function printf(1,"The first 25 abundant odd numbers are:\n") integer n = abundantOdd(1, 0, 25, true) printf(1,"The one thousandth abundant odd number is:") {} = abundantOdd(n, 25, 1000, false) printf(1,"The first abundant odd number above one billion is:") {} = abundantOdd(1e9+1, 0, 1, false)</lang>
- Output:
The first 25 abundant odd numbers are: 1. 945 (proper sum:975) 2. 1,575 (proper sum:1,649) 3. 2,205 (proper sum:2,241) 4. 2,835 (proper sum:2,973) 5. 3,465 (proper sum:4,023) 6. 4,095 (proper sum:4,641) 7. 4,725 (proper sum:5,195) 8. 5,355 (proper sum:5,877) 9. 5,775 (proper sum:6,129) 10. 5,985 (proper sum:6,495) 11. 6,435 (proper sum:6,669) 12. 6,615 (proper sum:7,065) 13. 6,825 (proper sum:7,063) 14. 7,245 (proper sum:7,731) 15. 7,425 (proper sum:7,455) 16. 7,875 (proper sum:8,349) 17. 8,085 (proper sum:8,331) 18. 8,415 (proper sum:8,433) 19. 8,505 (proper sum:8,967) 20. 8,925 (proper sum:8,931) 21. 9,135 (proper sum:9,585) 22. 9,555 (proper sum:9,597) 23. 9,765 (proper sum:10,203) 24. 10,395 (proper sum:12,645) 25. 11,025 (proper sum:11,946) The one thousandth abundant odd number is:492,975 (proper sum:519,361) The first abundant odd number above one billion is:1,000,000,575 (proper sum:1,083,561,009)
Python
<lang Python>
- !/usr/bin/python
numimpar = 1 contar = 0 sumaDiv = 0
from math import sqrt
def SumaDivisores(n):
# Devuelve la suma de los divisores propios de n suma = 1 i = int(sqrt(n)) for d in range (2, i): if n % d == 0: suma += d otroD = n // d if otroD != d: suma += otroD return suma
- los números requeridos por la tarea:
- primeros 25 números abundantes impares
print ("Los primeros 25 números impares abundantes:") while contar < 25:
sumaDiv = SumaDivisores(numimpar) if sumaDiv > numimpar: contar += 1 print("{0:5} suma divisoria adecuada: {1}". format(numimpar,sumaDiv)) numimpar += 2
- número impar abundante
while contar < 1000:
sumaDiv = SumaDivisores(numimpar) if sumaDiv > numimpar: contar += 1 numimpar += 2
print ("\n1000º número impar abundante:") print (f' {numimpar - 2} suma divisoria adecuada: {sumaDiv}')
- primer número impar abundante > mil millones (millardo)
numimpar = 1000000001 encontrado = False while not encontrado:
sumaDiv = SumaDivisores(numimpar) if sumaDiv > numimpar: encontrado = True print ("\nPrimer número impar abundante > 1 000 000 000:") print (f' {numimpar} suma divisoria adecuada: {sumaDiv}') numimpar += 2
</lang>
- Output:
Los primeros 25 números impares abundantes: 945 suma divisoria adecuada: 975 1575 suma divisoria adecuada: 1649 2205 suma divisoria adecuada: 2241 2835 suma divisoria adecuada: 2973 3465 suma divisoria adecuada: 4023 4095 suma divisoria adecuada: 4513 4725 suma divisoria adecuada: 5195 5355 suma divisoria adecuada: 5877 5775 suma divisoria adecuada: 5977 5985 suma divisoria adecuada: 6495 6435 suma divisoria adecuada: 6669 6615 suma divisoria adecuada: 7065 6825 suma divisoria adecuada: 7063 7245 suma divisoria adecuada: 7731 7425 suma divisoria adecuada: 7455 7875 suma divisoria adecuada: 8349 8085 suma divisoria adecuada: 8331 8415 suma divisoria adecuada: 8433 8505 suma divisoria adecuada: 8967 8925 suma divisoria adecuada: 8931 9135 suma divisoria adecuada: 9585 9555 suma divisoria adecuada: 9597 9765 suma divisoria adecuada: 10203 10395 suma divisoria adecuada: 12645 11025 suma divisoria adecuada: 11841 1000º número impar abundante: 492975 suma divisoria adecuada: 519361 Primer número impar abundante > 1 000 000 000: 1000000575 suma divisoria adecuada: 1083561009
REXX
A wee bit of coding was added to add commas (because of the larger numbers) as well as alignment of the output. <lang rexx>/*REXX pgm displays abundant odd numbers: 1st 25, one─thousandth, first > 1 billion. */ parse arg Nlow Nuno Novr . /*obtain optional arguments from the CL*/ if Nlow== | Nlow=="," then Nlow= 25 /*Not specified? Then use the default.*/ if Nuno== | Nuno=="," then Nuno= 1000 /* " " " " " " */ if Novr== | Novr=="," then Novr= 1000000000 /* " " " " " " */ numeric digits max(9, length(Novr) ) /*ensure enough decimal digits for // */ @= 'odd abundant number' /*variable for annotating the output. */
- = 0 /*count of odd abundant numbers so far.*/
do j=3 by 2 until #>=Nlow; $= sigO(j) /*get the sigma for an odd integer. */ if $<=j then iterate /*sigma ≤ J ? Then ignore it. */ #= # + 1 /*bump the counter for abundant odd #'s*/ say rt(th(#)) @ 'is:'rt(commas(j), 8) rt('sigma=') rt(commas($), 9) end /*j*/
say
- = 0 /*count of odd abundant numbers so far.*/
do j=3 by 2; $= sigO(j) /*get the sigma for an odd integer. */ if $<=j then iterate /*sigma ≤ J ? Then ignore it. */ #= # + 1 /*bump the counter for abundant odd #'s*/ if #<Nuno then iterate /*Odd abundant# count<Nuno? Then skip.*/ say rt(th(#)) @ 'is:'rt(commas(j), 8) rt('sigma=') rt(commas($), 9) leave /*we're finished displaying NUNOth num.*/ end /*j*/
say
do j=1+Novr%2*2 by 2; $= sigO(j) /*get sigma for an odd integer > Novr. */ if $<=j then iterate /*sigma ≤ J ? Then ignore it. */ say rt(th(1)) @ 'over' commas(Novr) "is: " commas(j) rt('sigma=') commas($) leave /*we're finished displaying NOVRth num.*/ end /*j*/
exit /*stick a fork in it, we're all done. */ /*──────────────────────────────────────────────────────────────────────────────────────*/ commas:parse arg _; do c_=length(_)-3 to 1 by -3; _=insert(',', _, c_); end; return _ rt: procedure; parse arg #,len; if len== then len= 20; return right(#, len) th: parse arg th; return th||word('th st nd rd',1+(th//10)*(th//100%10\==1)*(th//10<4)) /*──────────────────────────────────────────────────────────────────────────────────────*/ sigO: procedure; parse arg x; s= 1 /*sigma for odd integers. ___*/
do k=3 by 2 while k*k<x /*divide by all odd integers up to √ x */ if x//k==0 then s= s + k + x%k /*add the two divisors to (sigma) sum. */ end /*k*/ /* ___*/ if k*k==x then return s + k /*Was X a square? If so, add √ x */ return s /*return (sigma) sum of the divisors. */</lang>
- output when using the default input:
1st odd abundant number is: 945 sigma= 975 2nd odd abundant number is: 1,575 sigma= 1,649 3rd odd abundant number is: 2,205 sigma= 2,241 4th odd abundant number is: 2,835 sigma= 2,973 5th odd abundant number is: 3,465 sigma= 4,023 6th odd abundant number is: 4,095 sigma= 4,641 7th odd abundant number is: 4,725 sigma= 5,195 8th odd abundant number is: 5,355 sigma= 5,877 9th odd abundant number is: 5,775 sigma= 6,129 10th odd abundant number is: 5,985 sigma= 6,495 11th odd abundant number is: 6,435 sigma= 6,669 12th odd abundant number is: 6,615 sigma= 7,065 13th odd abundant number is: 6,825 sigma= 7,063 14th odd abundant number is: 7,245 sigma= 7,731 15th odd abundant number is: 7,425 sigma= 7,455 16th odd abundant number is: 7,875 sigma= 8,349 17th odd abundant number is: 8,085 sigma= 8,331 18th odd abundant number is: 8,415 sigma= 8,433 19th odd abundant number is: 8,505 sigma= 8,967 20th odd abundant number is: 8,925 sigma= 8,931 21st odd abundant number is: 9,135 sigma= 9,585 22nd odd abundant number is: 9,555 sigma= 9,597 23rd odd abundant number is: 9,765 sigma= 10,203 24th odd abundant number is: 10,395 sigma= 12,645 25th odd abundant number is: 11,025 sigma= 11,946 1000th odd abundant number is: 492,975 sigma= 519,361 1st odd abundant number over 1,000,000,000 is: 1,000,000,575 sigma= 1,083,561,009
Ring
<lang ring>
- Project: Anbundant odd numbers
max = 100000000 limit = 25 nr = 0 m = 1 check = 0 index = 0 see "working..." + nl see "wait for done..." + nl while true
check = 0 if m%2 = 1 nice(m) ok if check = 1 nr = nr + 1 ok if nr = max exit ok m = m + 1
end see "done..." + nl
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 if index < limit + 1 showArray(n,nArray,sum,index) ok if index = 100 see "One thousandth abundant odd number:" + nl showArray2(n,nArray,sum,index) ok if index = 100000000 see "First abundant odd number above one billion:" + nl showArray2(n,nArray,sum,index) ok ok
func showArray(n,nArray,sum,index)
see "" + index + ". " + string(n) + ": divisor sum: " for m = 1 to len(nArray) if m < len(nArray) see string(nArray[m]) + " + " else see string(nArray[m]) + " = " + string(sum) + nl + nl ok next
func showArray2(n,nArray,sum,index)
see "" + index + ". " + string(n) + ": divisor sum: " + see string(nArray[m]) + " = " + string(sum) + nl + nl
</lang>
working... wait for done... 1. 945: divisor sum: 1 + 3 + 5 + 7 + 9 + 15 + 21 + 27 + 35 + 45 + 63 + 105 + 135 + 189 + 315 = 975 2. 1575: divisor sum: 1 + 3 + 5 + 7 + 9 + 15 + 21 + 25 + 35 + 45 + 63 + 75 + 105 + 175 + 225 + 315 + 525 = 1649 3. 2205: divisor sum: 1 + 3 + 5 + 7 + 9 + 15 + 21 + 35 + 45 + 49 + 63 + 105 + 147 + 245 + 315 + 441 + 735 = 2241 4. 2835: divisor sum: 1 + 3 + 5 + 7 + 9 + 15 + 21 + 27 + 35 + 45 + 63 + 81 + 105 + 135 + 189 + 315 + 405 + 567 + 945 = 2973 5. 3465: divisor sum: 1 + 3 + 5 + 7 + 9 + 11 + 15 + 21 + 33 + 35 + 45 + 55 + 63 + 77 + 99 + 105 + 165 + 231 + 315 + 385 + 495 + 693 + 1155 = 4023 6. 4095: divisor sum: 1 + 3 + 5 + 7 + 9 + 13 + 15 + 21 + 35 + 39 + 45 + 63 + 65 + 91 + 105 + 117 + 195 + 273 + 315 + 455 + 585 + 819 + 1365 = 4641 7. 4725: divisor sum: 1 + 3 + 5 + 7 + 9 + 15 + 21 + 25 + 27 + 35 + 45 + 63 + 75 + 105 + 135 + 175 + 189 + 225 + 315 + 525 + 675 + 945 + 1575 = 5195 8. 5355: divisor sum: 1 + 3 + 5 + 7 + 9 + 15 + 17 + 21 + 35 + 45 + 51 + 63 + 85 + 105 + 119 + 153 + 255 + 315 + 357 + 595 + 765 + 1071 + 1785 = 5877 9. 5775: divisor sum: 1 + 3 + 5 + 7 + 11 + 15 + 21 + 25 + 33 + 35 + 55 + 75 + 77 + 105 + 165 + 175 + 231 + 275 + 385 + 525 + 825 + 1155 + 1925 = 6129 10. 5985: divisor sum: 1 + 3 + 5 + 7 + 9 + 15 + 19 + 21 + 35 + 45 + 57 + 63 + 95 + 105 + 133 + 171 + 285 + 315 + 399 + 665 + 855 + 1197 + 1995 = 6495 11. 6435: divisor sum: 1 + 3 + 5 + 9 + 11 + 13 + 15 + 33 + 39 + 45 + 55 + 65 + 99 + 117 + 143 + 165 + 195 + 429 + 495 + 585 + 715 + 1287 + 2145 = 6669 12. 6615: divisor sum: 1 + 3 + 5 + 7 + 9 + 15 + 21 + 27 + 35 + 45 + 49 + 63 + 105 + 135 + 147 + 189 + 245 + 315 + 441 + 735 + 945 + 1323 + 2205 = 7065 13. 6825: divisor sum: 1 + 3 + 5 + 7 + 13 + 15 + 21 + 25 + 35 + 39 + 65 + 75 + 91 + 105 + 175 + 195 + 273 + 325 + 455 + 525 + 975 + 1365 + 2275 = 7063 14. 7245: divisor sum: 1 + 3 + 5 + 7 + 9 + 15 + 21 + 23 + 35 + 45 + 63 + 69 + 105 + 115 + 161 + 207 + 315 + 345 + 483 + 805 + 1035 + 1449 + 2415 = 7731 15. 7425: divisor sum: 1 + 3 + 5 + 9 + 11 + 15 + 25 + 27 + 33 + 45 + 55 + 75 + 99 + 135 + 165 + 225 + 275 + 297 + 495 + 675 + 825 + 1485 + 2475 = 7455 16. 7875: divisor sum: 1 + 3 + 5 + 7 + 9 + 15 + 21 + 25 + 35 + 45 + 63 + 75 + 105 + 125 + 175 + 225 + 315 + 375 + 525 + 875 + 1125 + 1575 + 2625 = 8349 17. 8085: divisor sum: 1 + 3 + 5 + 7 + 11 + 15 + 21 + 33 + 35 + 49 + 55 + 77 + 105 + 147 + 165 + 231 + 245 + 385 + 539 + 735 + 1155 + 1617 + 2695 = 8331 18. 8415: divisor sum: 1 + 3 + 5 + 9 + 11 + 15 + 17 + 33 + 45 + 51 + 55 + 85 + 99 + 153 + 165 + 187 + 255 + 495 + 561 + 765 + 935 + 1683 + 2805 = 8433 19. 8505: divisor sum: 1 + 3 + 5 + 7 + 9 + 15 + 21 + 27 + 35 + 45 + 63 + 81 + 105 + 135 + 189 + 243 + 315 + 405 + 567 + 945 + 1215 + 1701 + 2835 = 8967 20. 8925: divisor sum: 1 + 3 + 5 + 7 + 15 + 17 + 21 + 25 + 35 + 51 + 75 + 85 + 105 + 119 + 175 + 255 + 357 + 425 + 525 + 595 + 1275 + 1785 + 2975 = 8931 21. 9135: divisor sum: 1 + 3 + 5 + 7 + 9 + 15 + 21 + 29 + 35 + 45 + 63 + 87 + 105 + 145 + 203 + 261 + 315 + 435 + 609 + 1015 + 1305 + 1827 + 3045 = 9585 22. 9555: divisor sum: 1 + 3 + 5 + 7 + 13 + 15 + 21 + 35 + 39 + 49 + 65 + 91 + 105 + 147 + 195 + 245 + 273 + 455 + 637 + 735 + 1365 + 1911 + 3185 = 9597 23. 9765: divisor sum: 1 + 3 + 5 + 7 + 9 + 15 + 21 + 31 + 35 + 45 + 63 + 93 + 105 + 155 + 217 + 279 + 315 + 465 + 651 + 1085 + 1395 + 1953 + 3255 = 10203 24. 10395: divisor sum: 1 + 3 + 5 + 7 + 9 + 11 + 15 + 21 + 27 + 33 + 35 + 45 + 55 + 63 + 77 + 99 + 105 + 135 + 165 + 189 + 231 + 297 + 315 + 385 + 495 + 693 + 945 + 1155 + 1485 + 2079 + 3465 = 12645 25. 11025: divisor sum: 1 + 3 + 5 + 7 + 9 + 15 + 21 + 25 + 35 + 45 + 49 + 63 + 75 + 105 + 147 + 175 + 225 + 245 + 315 + 441 + 525 + 735 + 1225 + 1575 + 2205 + 3675 = 11946 One thousandth abundant odd number: 1000. 492975: divisor sum: 1 + 3 + 5 + 7 + 9 + 15 + 21 + 25 + 35 + 45 + 63 + 75 + 105 + 175 + 225 + 313 + 315 + 525 + 939 + 1565 + 1575 + 2191 + 2817 + 4695 + 6573 + 7825 + 10955 + 14085 + 19719 + 23475 + 32865 + 54775 + 70425 + 98595 + 164325 = 519361 First abundant odd number above one billion: 100000000. 1000000575: divisor sum: 1 + 3 + 5 + 7 + 9 + 15 + 21 + 25 + 35 + 45 + 49 + 63 + 75 + 105 + 147 + 175 + 225 + 245 + 315 + 441 + 525 + 735 + 1225 + 1575 + 2205 + 3675 + 11025 + 90703 + 272109 + 453515 + 634921 + 816327 + 1360545 + 1904763 + 2267575 + 3174605 + 4081635 + 4444447 + 5714289 + 6802725 + 9523815 + 13333341 + 15873025 + 20408175 + 22222235 + 28571445 + 40000023 + 47619075 + 66666705 + 111111175 + 142857225 + 200000115 + 333333525 = 1083561009 done...
Visual Basic .NET
<lang vbnet>Module AbundantOddNumbers
' find some abundant odd numbers - numbers where the sum of the proper ' divisors is bigger than the number ' itself
' returns the sum of the proper divisors of n Private Function divisorSum(n As Integer) As Integer Dim sum As Integer = 1 For d As Integer = 2 To Math.Round(Math.Sqrt(n)) If n Mod d = 0 Then sum += d Dim otherD As Integer = n \ d IF otherD <> d Then sum += otherD End If End If Next d Return sum End Function
' find numbers required by the task Public Sub Main(args() As String) ' first 25 odd abundant numbers Dim oddNumber As Integer = 1 Dim aCount As Integer = 0 Dim dSum As Integer = 0 Console.Out.WriteLine("The first 25 abundant odd numbers:") Do While aCount < 25 dSum = divisorSum(oddNumber) If dSum > oddNumber Then aCount += 1 Console.Out.WriteLine(oddNumber.ToString.PadLeft(6) & " proper divisor sum: " & dSum) End If oddNumber += 2 Loop ' 1000th odd abundant number Do While aCount < 1000 dSum = divisorSum(oddNumber) If dSum > oddNumber Then aCount += 1 End If oddNumber += 2 Loop Console.Out.WriteLine("1000th abundant odd number:") Console.Out.WriteLine(" " & (oddNumber - 2) & " proper divisor sum: " & dSum) ' first odd abundant number > one billion oddNumber = 1000000001 Dim found As Boolean = False Do While Not found dSum = divisorSum(oddNumber) If dSum > oddNumber Then found = True Console.Out.WriteLine("First abundant odd number > 1 000 000 000:") Console.Out.WriteLine(" " & oddNumber & " proper divisor sum: " & dSum) End If oddNumber += 2 Loop End Sub
End Module</lang>
- Output:
The first 25 abundant odd numbers: 945 proper divisor sum: 975 1575 proper divisor sum: 1649 2205 proper divisor sum: 2241 2835 proper divisor sum: 2973 3465 proper divisor sum: 4023 4095 proper divisor sum: 4641 4725 proper divisor sum: 5195 5355 proper divisor sum: 5877 5775 proper divisor sum: 6129 5985 proper divisor sum: 6495 6435 proper divisor sum: 6669 6615 proper divisor sum: 7065 6825 proper divisor sum: 7063 7245 proper divisor sum: 7731 7425 proper divisor sum: 7455 7875 proper divisor sum: 8349 8085 proper divisor sum: 8331 8415 proper divisor sum: 8433 8505 proper divisor sum: 8967 8925 proper divisor sum: 8931 9135 proper divisor sum: 9585 9555 proper divisor sum: 9597 9765 proper divisor sum: 10203 10395 proper divisor sum: 12645 11025 proper divisor sum: 11946 1000th abundant odd number: 492975 proper divisor sum: 519361 First abundant odd number > 1 000 000 000: 1000000575 proper divisor sum: 1083561009
zkl
<lang zkl>fcn oddAbundants(startAt=3){ //--> iterator
Walker.zero().tweak(fcn(rn){ n:=rn.value; while(True){
sum:=0; foreach d in ([3.. n.toFloat().sqrt().toInt(), 2]){ if( (y:=n/d) *d != n) continue; sum += ((y==d) and y or y+d) } if(sum>n){ rn.set(n+2); return(n) } n+=2;
} }.fp(Ref(startAt.isOdd and startAt or startAt+1)))
}</lang> <lang zkl>fcn oddDivisors(n){ // -->sorted List
[3.. n.toFloat().sqrt().toInt(), 2].pump(List(1),'wrap(d){ if( (y:=n/d) *d != n) return(Void.Skip); if (y==d) y else T(y,d) }).flatten().sort()
} fcn printOAs(oas){ // List | int
foreach n in (vm.arglist.flatten()){ ds:=oddDivisors(n); println("%6,d: %6,d = %s".fmt(n, ds.sum(0), ds.sort().concat(" + "))) }
}</lang> <lang zkl>oaw:=oddAbundants();
println("First 25 abundant odd numbers:"); oaw.walk(25) : printOAs(_);
println("\nThe one thousandth abundant odd number is:"); oaw.drop(1_000 - 25).value : printOAs(_);
println("\nThe first abundant odd number above one billion is:"); printOAs(oddAbundants(1_000_000_000).next());</lang>
- Output:
945: 975 = 1 + 3 + 5 + 7 + 9 + 15 + 21 + 27 + 35 + 45 + 63 + 105 + 135 + 189 + 315 1,575: 1,649 = 1 + 3 + 5 + 7 + 9 + 15 + 21 + 25 + 35 + 45 + 63 + 75 + 105 + 175 + 225 + 315 + 525 2,205: 2,241 = 1 + 3 + 5 + 7 + 9 + 15 + 21 + 35 + 45 + 49 + 63 + 105 + 147 + 245 + 315 + 441 + 735 2,835: 2,973 = 1 + 3 + 5 + 7 + 9 + 15 + 21 + 27 + 35 + 45 + 63 + 81 + 105 + 135 + 189 + 315 + 405 + 567 + 945 3,465: 4,023 = 1 + 3 + 5 + 7 + 9 + 11 + 15 + 21 + 33 + 35 + 45 + 55 + 63 + 77 + 99 + 105 + 165 + 231 + 315 + 385 + 495 + 693 + 1155 4,095: 4,641 = 1 + 3 + 5 + 7 + 9 + 13 + 15 + 21 + 35 + 39 + 45 + 63 + 65 + 91 + 105 + 117 + 195 + 273 + 315 + 455 + 585 + 819 + 1365 4,725: 5,195 = 1 + 3 + 5 + 7 + 9 + 15 + 21 + 25 + 27 + 35 + 45 + 63 + 75 + 105 + 135 + 175 + 189 + 225 + 315 + 525 + 675 + 945 + 1575 5,355: 5,877 = 1 + 3 + 5 + 7 + 9 + 15 + 17 + 21 + 35 + 45 + 51 + 63 + 85 + 105 + 119 + 153 + 255 + 315 + 357 + 595 + 765 + 1071 + 1785 5,775: 6,129 = 1 + 3 + 5 + 7 + 11 + 15 + 21 + 25 + 33 + 35 + 55 + 75 + 77 + 105 + 165 + 175 + 231 + 275 + 385 + 525 + 825 + 1155 + 1925 5,985: 6,495 = 1 + 3 + 5 + 7 + 9 + 15 + 19 + 21 + 35 + 45 + 57 + 63 + 95 + 105 + 133 + 171 + 285 + 315 + 399 + 665 + 855 + 1197 + 1995 6,435: 6,669 = 1 + 3 + 5 + 9 + 11 + 13 + 15 + 33 + 39 + 45 + 55 + 65 + 99 + 117 + 143 + 165 + 195 + 429 + 495 + 585 + 715 + 1287 + 2145 6,615: 7,065 = 1 + 3 + 5 + 7 + 9 + 15 + 21 + 27 + 35 + 45 + 49 + 63 + 105 + 135 + 147 + 189 + 245 + 315 + 441 + 735 + 945 + 1323 + 2205 6,825: 7,063 = 1 + 3 + 5 + 7 + 13 + 15 + 21 + 25 + 35 + 39 + 65 + 75 + 91 + 105 + 175 + 195 + 273 + 325 + 455 + 525 + 975 + 1365 + 2275 7,245: 7,731 = 1 + 3 + 5 + 7 + 9 + 15 + 21 + 23 + 35 + 45 + 63 + 69 + 105 + 115 + 161 + 207 + 315 + 345 + 483 + 805 + 1035 + 1449 + 2415 7,425: 7,455 = 1 + 3 + 5 + 9 + 11 + 15 + 25 + 27 + 33 + 45 + 55 + 75 + 99 + 135 + 165 + 225 + 275 + 297 + 495 + 675 + 825 + 1485 + 2475 7,875: 8,349 = 1 + 3 + 5 + 7 + 9 + 15 + 21 + 25 + 35 + 45 + 63 + 75 + 105 + 125 + 175 + 225 + 315 + 375 + 525 + 875 + 1125 + 1575 + 2625 8,085: 8,331 = 1 + 3 + 5 + 7 + 11 + 15 + 21 + 33 + 35 + 49 + 55 + 77 + 105 + 147 + 165 + 231 + 245 + 385 + 539 + 735 + 1155 + 1617 + 2695 8,415: 8,433 = 1 + 3 + 5 + 9 + 11 + 15 + 17 + 33 + 45 + 51 + 55 + 85 + 99 + 153 + 165 + 187 + 255 + 495 + 561 + 765 + 935 + 1683 + 2805 8,505: 8,967 = 1 + 3 + 5 + 7 + 9 + 15 + 21 + 27 + 35 + 45 + 63 + 81 + 105 + 135 + 189 + 243 + 315 + 405 + 567 + 945 + 1215 + 1701 + 2835 8,925: 8,931 = 1 + 3 + 5 + 7 + 15 + 17 + 21 + 25 + 35 + 51 + 75 + 85 + 105 + 119 + 175 + 255 + 357 + 425 + 525 + 595 + 1275 + 1785 + 2975 9,135: 9,585 = 1 + 3 + 5 + 7 + 9 + 15 + 21 + 29 + 35 + 45 + 63 + 87 + 105 + 145 + 203 + 261 + 315 + 435 + 609 + 1015 + 1305 + 1827 + 3045 9,555: 9,597 = 1 + 3 + 5 + 7 + 13 + 15 + 21 + 35 + 39 + 49 + 65 + 91 + 105 + 147 + 195 + 245 + 273 + 455 + 637 + 735 + 1365 + 1911 + 3185 9,765: 10,203 = 1 + 3 + 5 + 7 + 9 + 15 + 21 + 31 + 35 + 45 + 63 + 93 + 105 + 155 + 217 + 279 + 315 + 465 + 651 + 1085 + 1395 + 1953 + 3255 10,395: 12,645 = 1 + 3 + 5 + 7 + 9 + 11 + 15 + 21 + 27 + 33 + 35 + 45 + 55 + 63 + 77 + 99 + 105 + 135 + 165 + 189 + 231 + 297 + 315 + 385 + 495 + 693 + 945 + 1155 + 1485 + 2079 + 3465 11,025: 11,946 = 1 + 3 + 5 + 7 + 9 + 15 + 21 + 25 + 35 + 45 + 49 + 63 + 75 + 105 + 147 + 175 + 225 + 245 + 315 + 441 + 525 + 735 + 1225 + 1575 + 2205 + 3675 The one thousandth abundant odd number is: 492,975: 519,361 = 1 + 3 + 5 + 7 + 9 + 15 + 21 + 25 + 35 + 45 + 63 + 75 + 105 + 175 + 225 + 313 + 315 + 525 + 939 + 1565 + 1575 + 2191 + 2817 + 4695 + 6573 + 7825 + 10955 + 14085 + 19719 + 23475 + 32865 + 54775 + 70425 + 98595 + 164325 The first abundant odd number above one billion is: 1,000,000,575: 1,083,561,009 = 1 + 3 + 5 + 7 + 9 + 15 + 21 + 25 + 35 + 45 + 49 + 63 + 75 + 105 + 147 + 175 + 225 + 245 + 315 + 441 + 525 + 735 + 1225 + 1575 + 2205 + 3675 + 11025 + 90703 + 272109 + 453515 + 634921 + 816327 + 1360545 + 1904763 + 2267575 + 3174605 + 4081635 + 4444447 + 5714289 + 6802725 + 9523815 + 13333341 + 15873025 + 20408175 + 22222235 + 28571445 + 40000023 + 47619075 + 66666705 + 111111175 + 142857225 + 200000115 + 333333525