n => { // n = input for( // main infinite loop: k = 0; // start with k = 0 a = []; // a[] = sequence of proper divisor sums ) ( // g = j => { // g is a recursive function takingthat takes an integer j, // fills the sequence a[] and prints it if valid for( // loop: s = // s is the proper divisor sum d = 0; // d is the current divisor ++d < j; // increment d; stop when it's equal to j s += j % d ? 0 : d // add d to s if d is a divisor of j ); // end of loop a.push(s) // push s into a[] < n ? // if there are less than n elements: s - k && g(s) // if s != k, do a recursive call with j = s : // else: s - k || print(a) // if s = k, print a[] } // end of g )(++k) // initial call to g with j = k incremented } // end of loop / end of function n => { // n = input for( // main infinite loop: k = 0; // start with k = 0 a = []; // a[] = sequence ) ( // g = j => { // g is a recursive function taking an integer j for( // loop: s = // s is the proper divisor sum d = 0; // d is the current divisor ++d < j; // increment d; stop when it's equal to j s += j % d ? 0 : d // add d to s if d is a divisor of j ); // end of loop a.push(s) // push s into a[] < n ? // if there are less than n elements: s - k && g(s) // if s != k, do a recursive call with j = s : // else: s - k || print(a) // if s = k, print a[] } // end of g )(++k) // initial call to g with j = k incremented } // end of function n => { // n = input for( // main infinite loop: k = 0; // start with k = 0 a = []; // a[] = sequence of proper divisor sums ) ( // g = j => { // g is a recursive function that takes an integer j, // fills the sequence a[] and prints it if valid for( // loop: s = // s is the proper divisor sum d = 0; // d is the current divisor ++d < j; // increment d; stop when it's equal to j s += j % d ? 0 : d // add d to s if d is a divisor of j ); // end of loop a.push(s) // push s into a[] < n ? // if there are less than n elements: s - k && g(s) // if s != k, do a recursive call with j = s : // else: s - k || print(a) // if s = k, print a[] } // end of g )(++k) // initial call to g with j = k incremented } // end of loop / end of function JavaScript (V8), 106 97 9796 bytes
Saved 1 byte thanks to @tsh
A function that takes \$n\$ and prints the sequence forever, including duplicates.
n=>{for(k=0;;k=0;a=[];)(a=[],g=j=>{for(s=d=0;++d<j;s+=j%d?0:d);a.push(s)<n?s-k&&g(s):s-k||print(a)})(++k)} n => { // n = input for( // main infinite loop: k = 0;;)0; ( // start with k = 0 and loop forever: a = [],[]; // a[] = sequence ) ( // g = j => { // g is a recursive function taking an integer j for( // loop: s = // s is the proper divisor sum d = 0; // d is the current divisor ++d < j; // increment d; stop when it's equal to j s += j % d ? 0 : d // add d to s if d is a divisor of j ); // end of loop a.push(s) // push s into a[] < n ? // if there are less than n elements: s - k && g(s) // if s != k, do a recursive call with j = s : // else: s - k || print(a) // if s = k, print a[] } // end of g )(++k) // initial call to g with j = k incremented } // end of function JavaScript (V8), 106 97 bytes
A function that takes \$n\$ and prints the sequence forever, including duplicates.
n=>{for(k=0;;)(a=[],g=j=>{for(s=d=0;++d<j;s+=j%d?0:d);a.push(s)<n?s-k&&g(s):s-k||print(a)})(++k)} n => { // n = input for(k = 0;;) ( // start with k = 0 and loop forever: a = [], // a[] = sequence g = j => { // g is a recursive function taking an integer j for( // loop: s = // s is the proper divisor sum d = 0; // d is the current divisor ++d < j; // increment d; stop when it's equal to j s += j % d ? 0 : d // add d to s if d is a divisor of j ); // end of loop a.push(s) // push s into a[] < n ? // if there are less than n elements: s - k && g(s) // if s != k, do a recursive call with j = s : // else: s - k || print(a) // if s = k, print a[] } // end of g )(++k) // initial call to g with j = k incremented } // end of function JavaScript (V8), 106 97 96 bytes
Saved 1 byte thanks to @tsh
A function that takes \$n\$ and prints the sequence forever, including duplicates.
n=>{for(k=0;a=[];)(g=j=>{for(s=d=0;++d<j;s+=j%d?0:d);a.push(s)<n?s-k&&g(s):s-k||print(a)})(++k)} n => { // n = input for( // main infinite loop: k = 0; // start with k = 0 a = []; // a[] = sequence ) ( // g = j => { // g is a recursive function taking an integer j for( // loop: s = // s is the proper divisor sum d = 0; // d is the current divisor ++d < j; // increment d; stop when it's equal to j s += j % d ? 0 : d // add d to s if d is a divisor of j ); // end of loop a.push(s) // push s into a[] < n ? // if there are less than n elements: s - k && g(s) // if s != k, do a recursive call with j = s : // else: s - k || print(a) // if s = k, print a[] } // end of g )(++k) // initial call to g with j = k incremented } // end of function Commented
n => { // n = input for(k = 0;;) ( // start with k = 0 and loop forever: a = [], // a[] = sequence g = j => { // g is a recursive function taking an integer j for( // loop: s = // s is the proper divisor sum d = 0; // d is the current divisor ++d < j; // increment d; stop when it's equal to j s += j % d ? 0 : d // add d to s if d is a divisor of j ); // end of loop a.push(s) // push s into a[] < n ? // if there are less than n elements: s - k && g(s) // if s != k, do a recursive call with j = s : // else: s - k || print(a) // if s = k, print a[] } // end of g )(++k) // initial call to g with j = k incremented } // end of function Commented
n => { // n = input for(k = 0;;) ( // start with k = 0 and loop forever: a = [], // a[] = sequence g = j => { // g is a recursive function taking an integer j for( // loop: s = // s is the proper divisor sum d = 0; // d is the current divisor ++d < j; // increment d; stop when it's equal to j s += j % d ? 0 : d // add d to s if d is a divisor of j ); // end of loop a.push(s) // push s into a[] < n ? // if there are less than n elements: s - k && g(s) // if s != k, do a recursive call with j = s : // else: s - k || print(a) // if s = k, print a[] } // end of g )(++k) // initial call to g with j = k incremented } // end of function