(* A109890 algorithm by Michael Thomas De Vlieger, St. Louis, MO 202404200930 *) (* This algorithm approaches solution by incrementation of sum s by adding a(n) *) (* then finding the smallest divisor of s that is not in the sequence by *) (* checking membership not by search, but by a check membership boolean variable *) (* If no divisor is valid, then we increment m(s) and check c(m(s)*s) until we *) (* find a multiple of s that is not in the sequence. *) nn = 2^14; (* Set generation limit *) c[_] := False; (* Check membership *) m[_] := 2; (* Multiplier variable *) a[1] = s = 1; c[1] = True; (* Initialize a(1) = 1 *) Monitor[Do[ If[IntegerQ[#], k = #, While[c[Set[k, s*m[s]], m[s]++] ] ] &@ SelectFirst[Divisors[s], ! c[#] &]; Set[{a[n], c[k]}, {k, True}]; s += k, {n, 2, nn}], n]; a109890 = Array[a, nn]; (* This variant sows the value of s to generate A109735. *) nn = 2^14; (* Set generation limit *) c[_] := False; (* Check membership *) m[_] := 2; (* Multiplier variable *) a[1] = s = 1; c[1] = True; (* Initialize a(1) = 1 *) a109735 = {1}~Join~Reap[Do[ If[IntegerQ[#], k = #, While[c[Set[k, s*m[s]], m[s]++] ] ] &@ SelectFirst[Divisors[s], ! c[#] &]; c[k] = True; Sow[s += k], {n, 2, nn}] ][[-1, 1]];