{"id":29142149,"url":"https://github.com/daedalus/myintegersequences","last_synced_at":"2026-02-06T16:33:22.306Z","repository":{"id":299674656,"uuid":"1003749154","full_name":"daedalus/MyIntegerSequences","owner":"daedalus","description":"My integer sequences","archived":false,"fork":false,"pushed_at":"2025-06-24T21:34:47.000Z","size":570,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-06-24T22:33:39.064Z","etag":null,"topics":["integer-sequences","oeis"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/daedalus.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-06-17T15:54:53.000Z","updated_at":"2025-06-24T21:34:50.000Z","dependencies_parsed_at":"2025-07-17T11:48:07.954Z","dependency_job_id":"649673c4-b37a-4bb0-bdeb-b4c283ec5ca8","html_url":"https://github.com/daedalus/MyIntegerSequences","commit_stats":null,"previous_names":["daedalus/myintegersequences"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/daedalus/MyIntegerSequences","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daedalus%2FMyIntegerSequences","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daedalus%2FMyIntegerSequences/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daedalus%2FMyIntegerSequences/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daedalus%2FMyIntegerSequences/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/daedalus","download_url":"https://codeload.github.com/daedalus/MyIntegerSequences/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daedalus%2FMyIntegerSequences/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29168529,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-06T15:38:29.831Z","status":"ssl_error","status_checked_at":"2026-02-06T15:37:48.592Z","response_time":59,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["integer-sequences","oeis"],"created_at":"2025-06-30T19:10:09.427Z","updated_at":"2026-02-06T16:33:22.281Z","avatar_url":"https://github.com/daedalus.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# My integer sequences. #\n\nThese are my integer sequences that at the day of this publishing are not in the [OEIS](https://oeis.org) database.\n\nThey are lincensed under the [Creative Commons Attribution Share-Alike 4.0 license (CC-BY-SA-4.0).](https://creativecommons.org/licenses/by-sa/4.0/)\n\nFor those sequences already in the database there is alread this [repo](https://github.com/daedalus/MyOEIS).\n\nFor an explanation of why these sequences are here and not in the OEIS, see [Issue #1](https://github.com/daedalus/MyIntegerSequences/issues/1).\n\n## Denominator of the product of Z(k) for k in [2,2n] where Z is the Riemann Zeta function. ##\n\n### DATA ###\n`6, 540, 510300, 4822335000, 451153550925000, 288067350867580659375000, 2627638748515609587313242187500, 855668397605812968586200315303076171875000, 33353351303282066817838186561741046895875775146484375000, 51074969616905297846770753353095329781107353215640111751556396484375000`\n\n### OFFSET ###\n1\n\n### FORMULA ###\n```\na(n) = denominator(Product_{k=2..2n} Zeta(k)).\na(n) = denominator(Product_{k=1..n} (Bernoulli(2*k) * 4^k) / (2*Factorial(2*k)))\n```\n\n### PROG ###\n```\n(Python)\nfrom sympy import denom\nfrom sympy.functions.special.zeta_functions import zeta\ndef a(n):\n  prod = 1\n  for k in range(2,2*n+1):\n    prod *= zeta(k)\n  return denom(prod)\nprint([a(n) for n in range(1, 11)])\n(Python)\nfrom sympy import bernoulli, factorial, denom\ndef a(n):\n    prod = 1\n    for k in range(1, n + 1):\n        k2 = k \u003c\u003c 1\n        B = bernoulli(k2)\n        prod *= (B * (1 \u003c\u003c (k2-1)) / factorial(k2))\n    return denom(prod)\nprint([a(n) for n in range(1, 11)])\n(Python)\nfrom sympy import bernoulli, factorial, gcd\ndef G():\n    k = 1\n    num, den = 1, 1\n    term_num, term_den = 1, 1\n    while True:\n        k2 = k \u003c\u003c 1\n        B = bernoulli(k2)\n        b_num, b_den = B.as_numer_denom()\n        term_num = b_num * (1 \u003c\u003c (k2-1))\n        term_den = b_den * factorial(k2) \n        if (g := gcd(term_num, term_den)) \u003e 1:\n            term_num //= g\n            term_den //= g\n        num *= term_num\n        den *= term_den\n        if (g := gcd(num, den)) \u003e 1:\n            num //= g\n            den //= g\n        yield den\n        k += 1\n    return den\nfrom itertools import islice\nprint(list(islice(G(), 10))) \n```\n\n### XREF ###\nCf. A000142.\n\n\n## a(n) = 2^m+r where m=min{m\u003e=1: binomial(m+1,2)\u003e=n} and r=binomial(m,2)-1. ##\n\n### DATA ###\n`2, 4, 5, 8, 9, 10, 16, 17, 18, 19, 32, 33, 34, 35, 36, 64, 65, 66, 67, 68, 69, 128, 129, 130, 131, 132, 133, 134, 256, 257, 258, 259, 260, 261, 262, 263, 512, 513, 514, 515, 516, 517, 518, 519, 520, 1024, 1025, 1026, 1027, 1028, 1029, 1030, 1031, 1032, 1033, 2048`\n\n\n### COMENTS ###\n```\na(n) = 2^m+r where m is the smallest m such that binomial(m,2) \u003c n \u003c= binomial(m+1,2) and r=binomial(m,2)-1 .\nSince a(n) is monotonically ascendant and a(1) = 2 it contains no fixed points.\n```\n\n### FORMULA ###\n```\na(n) = 2^m(n) + (n-1-(m(n)*m(n+1))/2) where m(n) = ceiling((-1+sqrt(1+8n))/2).\na(n) = 2^A002024(n) + A002262(n).\n```\n\n### PROG ###\n```\n(Python)\nfrom math import isqrt\ndef a(n):\n    m = (isqrt((n\u003c\u003c3)-7)+1) \u003e\u003e 1\n    r = (n - 1) - ((m * (m - 1)) \u003e\u003e 1)\n    return (1 \u003c\u003c m) | r\nprint([a(n) for n in range(1,57)])\n```\n\n### XREF ###\nCf. A002024, A002262, A003056.\n\n## Product of the totients of the antidivisors of n. ##\n\n### DATA ###\n`1, 1, 1, 2, 2, 2, 8, 8, 2, 24, 12, 16, 48, 24, 8, 20, 480, 192, 24, 96, 12, 768, 384, 48, 768, 64, 480, 5760, 36, 64, 864, 41472, 960, 88, 1056, 32, 1280, 153600, 1440, 1728, 216, 6144, 3584, 224, 27648, 8640, 4320, 1152, 14400, 38400, 32, 442368, 110592, 96, 2880, 576, 3168, 608256, 331776, 491520, 800, 12800, 69120, 84, 4032, 17280, 17915904, 663552, 44, 17664, 11040, 1720320, 677376, 12096, 1280`\n\n### COMMENTS ###\na(n) gives a sort of measure of how \"coprime\" the almost-divisors of n are. It is a highly non-monotonic and quite irregular function.\n\n### OFFSET ###\n1\n\n### FORMULA ###\na(n) = Product_{d in antidivisors(n)} totient(d).\n\n### PROG ###\n```\n(Python)\nfrom sympy.ntheory.factor_ import antidivisors\nfrom sympy import prod, totient\na = lambda n: prod(totient(d) for d in antidivisors(n))\nprint([a(n) for n in range(1, 76)])\n```\n\n### XREF ###\nCf. A000010, A091507.\n\n\n## Symmetric difference of sets: i*j and i+j for 1 \u003c= i, j \u003c= n. ##\n\n\n### COMMENTS ###\nprimepi(2n)-primepi(n) \u003e= 1 for n \u003e 1 is central to the Bertrand-Chevyshev theorem, which states that for any n\u003e1 always exist a prime p such that n \u003c p \u003c 2n.\n\n### DATA ###\n`2, 2, 3, 6, 7, 11, 16, 19, 25, 31, 38, 44, 53, 59, 68, 76, 89, 96, 113, 121, 133, 145, 164, 174, 188, 200, 215, 226, 251, 263, 292, 305, 321, 339, 357, 370, 405, 423, 442, 458, 495, 512, 551, 569, 590, 612, 655, 670, 701, 721, 748, 771, 820, 842, 873, 893, 923, 951, 1006, 1023, 1080, 1110, 1136`\n\n### FORMULA ###\n```\na(n) = primepi(2n) - primepi(n) + A375109(n).\na(n) = A000720(2n) - A000720(n) + A375109(n).\na(n) = A027424(n) - (2*n-1) + 2*(primepi(2n) - primepi(n)).\na(n) = A027424(n) - (2*n-1) + 2*(A000720(2n) - A000720(n)).\na(n) = A027424(n) - (2*n-1) + 2*(A108954(n)).\n```\n\n### LINKS ###\nWikipedia, \u003c a href=\"https://en.m.wikipedia.org/wiki/Bertrand%27s_postulate\"\u003eBertrand Postúlate\u003c/a\u003e.\n\n\n### PROG ###\n```\n(Python)\ndef a(n):\n    bs = ((1 \u003c\u003c (2*n+1)) - 2)\n    bp = 0\n    l = 2*n\n    for i in range(1, n+1):\n        for j in range(1, i+1):\n            bp |= 1 \u003c\u003c (i*j)\n    return (bs ^ bp).bit_count()+1\nprint([a(n) for n in range(1, 64)])\n(Python)\nfrom sympy import primepi\ndef a(n):\n    l = n \u003c\u003c 1\n    p = len({x \n             for i in range(1, n+1)\n             for j in range(1, i+1)\n             if (x:=i*j) \u003e l})\n    return primepi(l) - primepi(n) + p + 1\nprint([a(n) for n in range(1, 64)])\n```\n\n### XREF ###\nCf. A002446, A027424, A108954, A263995, A375109.\n\n\n\n\n## Number of distinct products i*j with 1 \u003c= i, j \u003c= n which are also the sum of two numbers between 1 and n. ##\n\n### DATA ###\n`0, 2, 4, 5, 8, 9, 11, 13, 14, 15, 18, 19, 22, 24, 25, 26, 29, 31, 33, 35, 36, 37, 40, 41, 43, 45, 46, 48, 51, 52, 54, 56, 58, 59, 61, 62, 64, 66, 68, 69, 72, 73, 76, 78, 79, 81, 84, 86, 87, 89, 90, 91, 94, 95, 96, 98, 99, 101, 104, 106, 109, 111, 113`\n\n### OFFSET ###\n1\n\n### COMMENTS ###\n```\nEssentialy the intersection of sets: distinct products i*j and distinct sums i+j for 1 \u003c= i, j \u003c= n.\nprimepi(2n)-primepi(n) \u003e= 1 for n \u003e 1 is central to the Bertrand-Chevyshev theorem, which states that for any n\u003e1 always exist a prime p such that n \u003c p \u003c 2n.\n```\n\n\n### FORMULA ###\n```\na(n) = 2n - 1 - (primepi(2n) - primepi(n)).\na(n) = A005408(n-2) - (A000720(2n) - A000720(n)).\n```\n\n### LINKS ###\nWikipedia, \u003c a href=\"https://en.m.wikipedia.org/wiki/Bertrand%27s_postulate\"\u003eBertrand Postúlate\u003c/a\u003e.\n\n\n### PROG ###\n```\n(Python)\ndef a(n):\n    # Runtime O(n log n).\n    l,s = n \u003c\u003c 1,0\n    s = 0\n    for i in range(1, n + 1):\n        m = min(n, l // i)\n        for j in range(1, m + 1):\n            s |= 1 \u003c\u003c (i*j)\n    return s.bit_count()-1\nprint([a(n) for n in range(1, 64)])\n(Python)\n# Runtime O(n log log n).\nfrom sympy import primepi\na = lambda n: 2*n - 1 - (primepi(2*n) - primepi(n))\nprint([a(n) for n in range(1, 64)])\n```\n\n### XREF ###\nCf. A000720, A005408, A108954, A263995, A375109.\n\n\n\n\n## Triangle T(n,k) where each k-th element is the k size MacMahon integer plane partition of n. ##\n\n### DATA ###\n`1, 3, 0, 4, 1, 0, 7, 3, 0, 0, 6, 9, 0, 0, 0, 12, 15, 1, 0, 0, 0, 8, 30, 3, 0, 0, 0, 0, 15, 45, 9, 0, 0, 0, 0, 0, 13, 67, 22, 0, 0, 0, 0, 0, 0, 18, 99, 42, 1, 0, 0, 0, 0, 0, 0, 12, 135, 81, 3, 0, 0, 0, 0, 0, 0, 0, 28, 175, 140, 9, 0, 0, 0, 0, 0, 0, 0, 0`\n\n### COMMENTS ###\nM(j,n) is the MacMahon plane partition function and is defined as the sum over all partitions of n into exactly j distinct parts, each such partition contributing the product of multiplicities of the parts.\n\n### OFFSET ###\n1\n\n### LINK ###\nWikipedia, \u003ca href=\"https://en.wikipedia.org/wiki/Plane_partition\"\u003ePlane partition\u003c/a\u003e.\n\n### FORMULA ###\n```\nM(1,n) = A000203(n)\nM(2,n) = A002127(n) for n\u003e= 3 else 0.\nM(3,n) = A002128(n) for n\u003e= 6 else 0.\n```\n\n### PROG ###\n```\n(Python)\ndef M(j, n):\n    dp = [ [0]*(n+1) for _ in range(j+1) ]\n    dp[0][0] = 1\n    for s in range(1, n+1):\n        for l in range(j-1, -1, -1):\n            for t in range(n - s + 1):\n                if (val := dp[l][t]):\n                    for m in range(1, (n - t) // s + 1):\n                        dp[l+1][t + m * s] += val * m\n    return dp[j][n]\nrow = lambda n: [M(k,n) for k in range (1,n+1)]\n```\n\n### KEYWORD ###\ntabl\n\n### XREF ###\nCf. A000203, A002127, A002128.\n\n\n\n\n## a(n) = (n^2-3n+2)*M(1,n) - 8*M(2,n). ##\n\n### DATA ###\n`0, 0, 0, 18, 0, 120, 0, 270, 192, 504, 0, 1680, 0, 1296, 1536, 2790, 0, 5160, 0, 6804, 3840, 4680, 0, 16800, 2880, 7560, 7680, 17280, 0, 30960, 0, 25110, 13440, 16416, 13824, 59490, 0, 22680, 21504, 66780, 0, 78720, 0, 61776, 59136, 39600, 0, 148800, 16128, 86184`\n\n### COMMENTS ###\nM(j,n) is the MacMahon plane partition function and is defined as the sum over all partitions of n into exactly j distinct parts, each such partition contributing the product of multiplicities of the parts.\n\n### FORMULA ###\n```\na(n) = 0 iff n is prime.\nM(1,n) = A000203(n)\nM(2,n) = A002127(n) for n\u003e= 3 else 0.\na(n) = A279019(n-4)*M(1,n) - 8*M(2,n).\n```\n\n### OFFSET ###\n1\n\n### LINK ###\nWilliam Craig, Jan-Willem van Ittersum, Ken Ono, \u003ca href=\"https://arxiv.org/abs/2405.06451\"\u003eInteger partitions detect the primes\u003c/a\u003e.\n\nWikipedia, \u003ca href=\"https://en.wikipedia.org/wiki/Plane_partition\"\u003ePlane partition\u003c/a\u003e.\n\n### PROG ###\n```\n(Python)\ndef M(j, n):\n    dp = [ [0]*(n+1) for _ in range(j+1) ]\n    dp[0][0] = 1\n    for s in range(1, n+1):\n        for l in range(j-1, -1, -1):\n            for t in range(n - s + 1):\n                if (val := dp[l][t]):\n                    for m in range(1, (n - t) // s + 1):\n                        dp[l+1][t + m * s] += val * m\n    return dp[j][n]\ndef a(n):\n    return (n**2-3*n+2)*M(1,n) - 8*M(2,n)\nprint([a(n) for n in range(1,51)])\n```\n\n### XREF ###\nCf. A000203, A002127, A002128, A279019.\n\n\n\n## a(n) = (3n^3 - 13n^2 + 18n - 8) * M(1,n) + (12n^2 -120n + 212)* M(2,n) - 960*M(3,n) with M(j,n) the MacMahon partition function. ##\n\n### DATA ###\n`0, 0, 0, 108, 0, 1260, 0, 4860, 2592, 14364, 0, 51660, 0, 75816, 43776, 169020, 0, 367380, 0, 551124, 213120, 723060, 0, 1745100, 108000, 1666980, 725760, 2854440, 0, 5059800, 0, 5525820, 1955520, 6377616, 808704, 13324320, 0, 11124540, 4483584, 18193140, 0`\n\n### COMMENTS ###\nM(j,n) is the MacMahon plane partition function and is defined as the sum over all partitions of n into exactly j distinct parts, each such partition contributing the product of multiplicities of the parts.\n\n### FORMULA ###\n```\na(n) = 0 iff n is prime.\nM(1,n) = A000203(n)\nM(2,n) = A002127(n) for n\u003e= 3 else 0.\nM(3,n) = A002128(n) for n\u003e= 6 else 0.\n```\n\n### OFFSET ###\n1\n\n### LINK ###\nWilliam Craig, Jan-Willem van Ittersum, Ken Ono, \u003ca href=\"https://arxiv.org/abs/2405.06451\"\u003eInteger partitions detect the primes\u003c/a\u003e.\n\nWikipedia, \u003ca href=\"https://en.wikipedia.org/wiki/Plane_partition\"\u003ePlane partition\u003c/a\u003e.\n\n### PROG ###\n```\n(Python)\ndef M(j, n):\n    dp = [ [0]*(n+1) for _ in range(j+1) ]\n    dp[0][0] = 1\n    for s in range(1, n+1):\n        for l in range(j-1, -1, -1):\n            for t in range(n - s + 1):\n                if (val := dp[l][t]):\n                    for m in range(1, (n - t) // s + 1):\n                        dp[l+1][t + m * s] += val * m\n    return dp[j][n]\ndef a(n):\n    term1 = M(1, n) * (3 * n**3 - 13 * n**2 + 18 * n - 8)\n    term2 = M(2, n) * (12 * n**2 - 120 * n + 212)\n    term3 = M(3, n) * 960\n    return term1 + term2 - term3\nprint([a(n) for n in range(1,42)])\n````\n\n### XREF ###\nCf. A000203, A002127, A002128.\n\n\n\n## a(n) is the sum of pairs x+y such that (x^2+y^2)/(xy+1) is square for x,y in [0, n-1]. ##\n\n### DATA ###\n`0, 4, 8, 14, 22, 32, 44, 58, 94, 112, 132, 154, 178, 204, 232, 262, 294, 328, 364, 402, 442, 484, 528, 574, 622, 672, 724, 838, 894, 952, 1088, 1150, 1214, 1280, 1348, 1418, 1490, 1564, 1640, 1718, 1798, 1880, 1964, 2050, 2138, 2228, 2320, 2414, 2510, 2608, 2708`\n\n### COMMENT ###\nThe function is symmetric in x,y because (x,y) = (y,x).\n\n### FORMULA ###\n`a(n) = Sum_{x=0..n-1} Sum_{y=0..n-1} x+y iif (x^2 + y^2)/(xy+1) is square.`\n\n### LINKS ###\nNumberphile, \u003ca href=\"https://www.youtube.com/watch?v=NcaYEaVTA4g\"\u003eThe notorious question six (solved by induction)\u003c/a\u003e.\n\n### PROG ###\n```\n(Python)\nfrom sympy.ntheory.primetest import is_square\ndef a(n):\n  if n == 1: return 0\n  c = 0\n  for x in range(1,n):\n    x2 = x*x\n    for y in range(x+1,n):\n      q,r = divmod(x2 + y*y, x*y + 1) \n      if r == 0 and is_square(q):\n        c += (x+y)\n  return c*2+2+n*(n-1)\nprint([a(n) for n in range(1,52)])\n```\n\n\n## Number of solutions that satisfy x^2 + y^2 + w^2 + z^2 = xywz for x,y,w,z in [1,n]. ##\n\n### DATA ###\n`0, 1, 1, 1, 1, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17`\n\n### LINKS ###\nNumberphile, \u003ca href=\"https://www.youtube.com/watch?v=a7BVL1MOCl4\"\u003eA simple equation that behaves strangely\u003c/a\u003e.\n\nWikipedia, \u003ca href=\"https://en.wikipedia.org/wiki/Vieta_jumping\"\u003eVieta jumping\u003c/a\u003e.\n\n### FORMULA ###\n`a(f(n)+c) = g(n), for c \u003c f(n+1) with f=2*A0752762 and g remaining to be defined.`\n\n### PROG ###\n```\n(Python)\nfrom itertools import combinations_with_replacement\nfrom math import factorial\nfrom collections import Counter\ndef a(n):\n    if n == 1: return 0\n    if n \u003c 6: return 1\n    c,f4 = 0, 4*3*2\n    F={}\n    for x, y, w, z in combinations_with_replacement(range(1, n+1), 4):\n        if x**2 + y**2 + w**2 + z**2 == x*y*w*z:\n            m = Counter([x, y, w, z])  \n            perms = f4\n            for v in m.values():\n                if v in F:\n                    perms //= F[v]\n                else:\n                    F[v] = factorial(v)\n                    perms //= factorial(v)\n            c += perms\n    return c\nprint([a(n) for n in range(1,71)])\n```\n\n### XREF ###\nCf. A075276.\n\n\n\n## Number of distinct values of f(x,y) = x*y mod x+y for x,y in the range [1,n]. ##\n\n### DATA ###\n`1, 3, 4, 6, 7, 9, 10, 10, 13, 15, 16, 18, 21, 21, 23, 24, 26, 28, 30, 31, 32, 35, 37, 38, 42, 43, 44, 46, 47, 48, 51, 52, 54, 57, 58, 61, 64, 65, 67, 68, 70, 72, 75, 76, 77, 78, 79, 81, 82, 85, 86, 90, 92, 93, 95, 97, 98, 100, 102, 104, 106, 107, 109, 111, 113`\n\n### OFFSET ###\n1\n\n### COMMENTS ###\n```\na(n) is simetric because f(x,y) = f(y,x).\na(n) grows ∼ n + floor(n/2).\na(n) \u003c= 2*n-1.\n```\n\n### PROG ###\n```\n(Python)\ndef a(n):\n  D = set()\n  for x in range(1,n+1):\n    for y in range(x,n+1):\n      D.add((x*y) % (x+y))\n  return len(D)\n  print([a(n) for n in range(1,66)])\n```\n\n\n\n## a(n) is the order of the Hadamard Matrix not constructible with Sylvester's or Paley's methods alone. ###\n\n### DATA ###\n`40, 52, 56, 88, 92, 96, 100, 112, 116, 120, 136, 144, 156, 160, 172, 176, 184, 188, 208, 216, 232, 236, 244, 248, 260, 268, 280, 288, 292, 296, 304, 320, 324, 328, 336, 340, 344, 352, 356, 372, 376, 392, 400, 404, 408, 412, 416, 424, 428, 436, 448, 452, 456, 472`\n\n### OFFSET ###\n1\n\n### LINKS ###\nEric Weisstein's World of Mathematics, \u003ca href=\"https://mathworld.wolfram.com/HadamardMatrix.html\"\u003eHadamard Matrix\u003c/a\u003e.\n\nWikipedia, \u003ca href=\"https://en.m.wikipedia.org/wiki/Hadamard_matrix\"\u003eHadamard Matrix\u003c/a\u003e.\n\n### XREF ###\nCf. A003432.\n\n\n\n## Sum of distinct values of the quadratic discriminant D=b^2-4ac, for a,b,c in the range [-n,n]. ##\n\n### DATA ###\n`3, 27, 121, 271, 785, 1497, 3102, 4646, 7191, 11040, 17042, 22212, 33547, 46227, 60289, 72515, 102447, 120770, 154047, 180511, 222252, 268785, 349006, 386829, 461894, 531422, 620106, 703939, 836929, 941338, 1134204, 1239196, 1400083, 1632960, 1818962, 1936320, 2270656`\n\n### OFFSET ###\n1\n\n### COMMENTS ###\nConversely the count of distinct values of the quadratic discriminant D=b^2-4ac, for a,b,c in the range [-n,n] is A384666.\n\n### PROG ###\n```\n(Python)\ndef a(n):\n    D, ac = {0}, {0}\n    SQ = [i*i for i in range(0, n+1)]\n    for i in range(1, n+1):\n        ac.add(i)\n        if (s:= SQ[i]) \u003e n:\n            ac.add(s)\n    if n \u003e 2:\n        for a_ in range(2, n):\n            for c in range(a_ + 1, n + 1):\n                ac.add(a_ * c)\n    for b in range(n + 1):\n        b2 = SQ[b]\n        for v in ac:\n            ac4 = v \u003c\u003c 2\n            D.add(b2 + ac4)\n            if b2 \u003c ac4:\n                D.add(b2 - ac4)\n    return sum(D)\nprint([a(n) for n in range(1, 38)])\n```\n\n### XREF ###\nCf. A384666.\n\n\n\n## The totient of the product of the totients of the unitary divisors of n. ##\n\n### DATA ###\n`1, 1, 1, 1, 2, 2, 2, 2, 2, 8, 4, 8, 4, 12, 32, 4, 8, 12, 6, 32, 48, 40, 10, 32, 8, 48, 6, 48, 12, 2048, 8, 8, 160, 128, 192, 48, 12, 108, 192, 128, 16, 6912, 12, 160, 192, 220, 22, 128, 12, 160, 512, 192, 24, 108, 640, 192, 432, 336, 28, 32768, 16, 240, 432, 16`\n\n### OFFSET ###\n1\n\n### FORMULA ###\n```\na(p) = totient(Product{d|n} totient(d) if gcd(d, n/d)=1).\na(n) = totient(totient(n)^(2^(omega(n)-1))).\na(n) = A000010(A384763(n)).\na(p) = A008330(p) for p prime.\n```\n\n### PROG ###\n```\n(Python)\nfrom sympy import totient, divisors, gcd\ndef a(n):\n   prod = 1\n   for d in divisors(n):\n      if gcd(d, n//d) == 1:\n          prod *= totient(d)\n   return totient(prod)\nprint([a(n) for n in range(1, 65)])\n(Python)\nfrom sympy import factorint, divisors, gcd, totient, prod\ndef a(n):\n    if n == 1: return 1\n    pe = {}\n    for d in divisors(n):\n        if gcd(d, n // d) == 1:\n            for p, e in factorint(totient(d)).items():\n                pe[p] = pe.get(p, 0) + e\n    return prod(p**(e - 1) * (p - 1) for p,e in pe.items())\nprint([a(n) for n in range(1, 65)])\n(Python)\nfrom sympy import factorint, divisors, gcd, totient, prod\ndef a(n):\n    if n == 1: return 1\n    pe = []\n    for d in divisors(n):\n        if gcd(d, n // d) == 1:\n            pe.extend(factorint(totient(d)).items())\n    primes = sorted(set(p for p, _ in pe))\n    return prod(p**(sum(e for q, e in pe if q == p) - 1) * (p - 1) for p in primes)\nprint([a(n) for n in range(1, 65)])\n```\n\n### XREF ###\nCf. A000010, A008330, A384763.\n\n\n\n## The integer representation of the reversal of the Reed-Muller code of size 2^(n+1)-1. ##\n\n### DATA ###\n`1, 14, 3820, 4006538480, 1127740325610919595933440, 5855562549912621432400532814181205703033719227392014090240, 678027821314169029533837277126308108243817843666549070645730770517828410950207716447345344965940166970542012394294840655177503788236800`\n\n### COMMENTS ###\n```\nReed-Muller codes are created such that H(0) is 1 and H(n) is a concatenation equal to: 2^(n-1) zeros plus 2^(n-1) ones plus two copies of H(n-1).\nTypically, these codes contain leading zeros. To avoid ignoring them and loss of general information, we reverse the code, since they always end in ones.\nA self-similar structure can easily be observed in the binary expansion of a(n).\nThe bitsize of a(n) is n*2^(n-1).\n```\n\n### OFFSET ###\n0\n\n### FORMULA ###\n`a(n+1) mod a(n) = A111403(n) for n \u003e= 1.`\n\n### EXAMPLE ###\n```\nThe Reed-muller PROGs are:\n n | H(n)                                | reversed                         | a(n)\n---+-------------------------------------+----------------------------------+------\n 0 | 1                                   | 1                                | 1\n 1 | 0 1 11                              | 1110                             | 14\n 2 | 00 11 0111 0111                     | 111011101100                     | 3820\n 3 | 0000 1111 001101110111 001101110111 | 11101110110011101110110011110000 | 4006538480\n```\n\n### LINK ###\nYoutube, \u003ca href=\"https://www.youtube.com/watch?v=CtOCqKpti7s\"\u003eReed-Muller code (64 Shades of Grey pt2) - Computerphile\u003c/a\u003e.\n\n### PROG ###\n```\n(Python)\nfrom functools import cache\n@cache\ndef H(n):\n  if n == 0: return \"1\"\n  m =  (1 \u003c\u003c (n-1))\n  prev = H(n-1)\n  return m * \"0\" + m * \"1\" + 2*prev\na = lambda n: int(H(n)[::-1],2)\nprint([a(n).bit_length() for n in range(7)])\n```\n\n### KEYWORD ###\nbase\n\n### XREF ###\nCf. A000225, A001787, A036289.\n\n\n\n## Number of distinct subsets S of [1..n] such that for all 1 \u003c= k \u003c= n, there exists two elements x,y in S (not necessarily distinct) such that x*y = k^2. ##\n\n### DATA ###\n`0, 1, 1, 1, 2, 2, 2, 2, 3, 10, 10, 10, 11, 11, 11, 11, 37, 37, 40, 40, 80, 80, 80, 80, 80, 592, 592, 1076`\n\n### OFFSET ###\n0\n\n### EXAMPLE ###\n```\nFor n=5 a(5) = 2, because there are three sets that matches the said condition:\n{1, 3, 4, 5} and {1, 2, 3, 4, 5}\n```\n\n### PROG ###\n```\n(Python)\ndef a(n):\n    t = set(k*k  for k in range(1, n+1))\n    c = 0\n    for i in range(1, (1 \u003c\u003c n)+1, 2):\n        s = [j+1 for j in range(n) if (i \u003e\u003e j) \u0026 1]\n        if len(s) == 0 or s[0] != 1 or s[-1] != n: continue\n        ss = set(x * y for x in s for y in s)\n        if t.issubset(ss):\n            c += 1\n    return c\n```\n\n### KEYWORD ###\nnonn,more\n\n### XREFS ###\nCf. A383968.\n\n\n\n## Number of remainders n mod p greater than zero, over all primes p \u003c n. ##\n\n### DATA ###\n`1, 1, 2, 2, 3, 2, 4, 4, 4, 3, 5, 4, 6, 5, 5, 6, 7, 6, 8, 7, 7, 7, 9, 8, 9, 8, 9, 8, 10, 8, 11, 11, 10, 10, 10, 10, 12, 11, 11, 11, 13, 11, 14, 13, 13, 13, 15, 14, 15, 14, 14, 14, 16, 15, 15, 15, 15, 15, 17, 15, 18, 17, 17, 18, 17, 16, 19, 18, 18, 17, 20, 19, 21`\n\n### OFFSET ###\n1\n\n### FORMULA ###\n`a(A000040(n)) = n.`\n\n### PROG ###\n```\n(Python)\nfrom sympy import primerange\ndef a(n):\n    s = 1\n    for p in primerange(0, n):\n        if p \u003e (n \u003e\u003e 1): s += 1\n        elif (n % p) \u003e 0: s += 1\n    return s\nprint([a(n) for n in range(1,74)])\n```\n\n### XREF ###\nCf. A000040, A383752.\n\n\n\n## Apply Rule 110 as an encoding to the binary expansion of n. ##\n\n### DATA ###\n`0, 0, 2, 0, 6, 2, 6, 0, 6, 6, 14, 2, 14, 6, 6, 0, 6, 6, 14, 6, 30, 14, 22, 2, 22, 14, 30, 6, 30, 6, 6, 0, 6, 6, 14, 6, 30, 14, 22, 6, 54, 30, 62, 14, 62, 22, 38, 2, 38, 22, 46, 14, 62, 30, 54, 6, 54, 30, 62, 6, 30, 6, 6, 0, 6, 6, 14, 6, 30, 14, 22, 6, 54, 30`\n\n### COMMENTS ###\nLeading zeros are omitted.\n\n### LINKS ###\nWikipedia, \u003ca href=\"https://en.wikipedia.org/wiki/Rule_110\"\u003eRule 110\u003c/a\u003e.\n\n### EXAMPLE ###\n```\nFor n = 52, a(52) = 14 because:\n52 = 110100_2 and\nAplying the Rule 110 we get:\n Current Pattern | new pattern\n-----------------+-------------\n 110             | 1\n  101            | 1\n   010           | 1\n    100          | 0\n     00          | 0\n      0          | 0\nand 111000_2 = 14.\n```\n\n### PROG ###\n```\n(Python)\ndef a(n):\n    m = int(bin(n)[2:][::-1],2)\n    R110 = {0:0,1:1,2:1,3:1,4:0,5:1,6:1,7:0}\n    e = 0\n    mask = 0b111\n    while m:\n        m \u003e\u003e= 1\n        e |= R110[m \u0026 mask]\n        e \u003c\u003c= 1\n    return e \u003e\u003e 1\nprint([a(n) for n in range(1,75)])\n```\n\n### KEYWORD ###\nbase\n\n\n\n## Number of remainders n mod p equal zero, over all primes p \u003c n. ##\n\n### DATA ###\n`1, 1, 1, 2, 1, 3, 1, 2, 2, 3, 1, 3, 1, 3, 3, 2, 1, 3, 1, 3, 3, 3, 1, 3, 2, 3, 2, 3, 1, 4, 1, 2, 3, 3, 3, 3, 1, 3, 3, 3, 1, 4, 1, 3, 3, 3, 1, 3, 2, 3, 3, 3, 1, 3, 3, 3, 3, 3, 1, 4, 1, 3, 3, 2, 3, 4, 1, 3, 3, 4, 1, 3, 1, 3, 3, 3, 3, 4, 1, 3, 2, 3, 1, 4, 3, 3, 3`\n\n### OFFSET ###\n1\n\n### FORMULA ###\n`a(p) = 2 if p is an odd prime.`\n\n### PROG ###\n```\n(Python)\nfrom sympy import primerange\ndef a(n):\n    s = 1\n    for p in primerange(0, (n \u003e\u003e 1) + 1):\n        if (n % p) == 0: s += 1\n    return s\nprint([a(n) for n in range(1,88)])\n```\n\n### XREF ###\nCf. A000040, A383752.\n\n\n\n## The bit position of the bit flip to obtain the longest run of 1s in the binary expansion of n, 1-indexed and 0 if no bit flip was possible. ##\n\n### DATA ###\n`1, 0, 1, 0, 1, 2, 1, 0, 1, 2, 3, 3, 1, 2, 1, 0, 1, 2, 3, 3, 4, 2, 4, 4, 1, 2, 3, 3, 1, 2, 1, 0, 1, 2, 3, 3, 4, 2, 4, 4, 5, 5, 3, 3, 5, 5, 5, 5, 1, 2, 3, 3, 4, 2, 4, 4, 1, 2, 3, 3, 1, 2, 1, 0, 1, 2, 3, 3, 4, 2, 4, 4, 5, 2, 3, 3, 5, 2, 5, 5, 6, 6, 6, 3, 4, 2, 4, 4`\n\n### COMMENTS ###\nThe longest run of 1s in the binary expansion of n is given by A383270(n).\n\n### OFFSET ###\n0\n\n### FORMULA ###\n```\na(2^k-1) = 0 if k \u003e 0.\na(2^k) = 1\na(2^k+1) = 2 if k \u003e 1.\n```\n\n### PROG ###\n```\n(Python)\ndef a(n):\n    if n == 0: return 1\n    if n.bit_length() == n.bit_count(): return 0\n    b = c = i = p = m = 0\n    while n:\n        if n \u0026 1: c += 1\n        else:\n            p = c * ((n \u0026 2) \u003e 0)\n            if (pc := p + c) \u003e m:\n                m,b = pc,i\n            c = 0\n        n \u003e\u003e= 1\n        i += 1\n    return b+1\nprint([a(n) for n in range(0,88)])\n```\n\n### KEYWORD ###\nbase\n\n### XREF ###\nCf. A383270.\n\n\n\n\n## Number of distinct values of j^2-i^2 for i,j in range [1,n]. ##\n\n### DATA ###\n`1, 2, 4, 7, 11, 16, 21, 26, 32, 41, 47, 56, 65, 74, 86, 97, 107, 118, 130, 144, 158, 173, 187, 204, 221, 238, 255, 272, 288, 309, 328, 347, 366, 389, 411, 434, 456, 479, 504, 530, 553, 581, 605, 633, 662, 689, 717, 747, 774, 804, 834, 868, 896, 931, 968, 1001`\n\n### OFFSET ###\n1\n\n### PROG ###\n```\n(Python)\ndef a(n):\n    s = set()\n    for i in range(1,n+1):\n      for j in range(i,n+1):\n          s.add(j*j-i*i)\n    return len(s)\nprint([a(n) for n in range(1,57)])\n```\n\n\n\n## Number of solutions wining the Tchoukaillon game with 2n seeds and n pits. ##\n\n### DATA ###\n`1, 0, 0, 1, 9, 71, 531, 3836, 27073, 187959, 1289718, 8775209, 59342609, 399533919, 2681325612, 17953216130, 120009760270, 801276639051, 5345587080397, 35642710395824, 237571467879718, 1583179263631879, 10549354995548345, 70293849142393155`\n\n### OFFSET ###\n0\n\n### COMMENTS ###\na(n) is the number of permutations of [n+1] with n*(n+1)/2 inversions.\n\n### FORMULA ###\n```\na(n) = T(n,2n) with T(i,r) = Sum_{v=0..min(i,r)} T(i-1, r-v) and T(0,r) = 1 if r = 0 else 0.\na(n) = A008302(n+1, A000217(n)) for n \u003e= 2.\n```\n\n### LINKS ###\nMancala World, \u003ca href=\"https://mancala.fandom.com/wiki/Tchoukaillon\"\u003eTchoukaillon\u003c/a\u003e.\n\n### PROG ###\n```\n(Python)\nfrom functools import lru_cache\ndef a(n):\n    @lru_cache(maxsize=None)\n    def T(i, r):\n        if i == 0:\n            return 1 if r == 0 else 0\n        return sum(T(i - 1, r - v) for v in range(min(i, r) + 1))\n    return T(n, n*2)\nprint([a(n) for n in range(0,24)])\n```\n\n### XREF ###\nCf. A000707, A383454.\n\n\n\n## Number of solutions wining the Tchoukaillon game with n seeds and n^2 pits. ##\n\n### DATA ###\n`1, 1, 9, 155, 3723, 115480, 4405035, 199766491, 10508057625, 629280966619, 42282286220836, 3150585380260000, 257864665508695118, 22998694581983709355, 2220257469063898905802, 230669987024626328456534, 25662670635977625719048303, 3043998217222850740624118838, 383488586060201709909994560725`\n\n### COMMENTS ###\na(n) is the number of permutations of [A098749(n)] with n+1 inversions.\n\n### OFFSET ###\n0\n\n### FORMULA ###\n```\na(n) = T(n*n,n) with T(x,y) = Sum_{v=0..min(x,y)} T(x-1, y-v) and T(0,y) = 1 if y = 0 else 0.\na(n) = A008302(A098749(n), n+1)\n```\n\n### PROG ###\n```\n(Python)\nfrom functools import lru_cache\ndef a(n):\n    @lru_cache(maxsize=None)\n    def T(i, r):\n        if i == 0:\n            return 1 if r == 0 else 0\n        return sum(T(i - 1, r - v) for v in range(min(i, r) + 1) if r - v \u003e= 0)\n    return T(n*n, n)\nprint([a(n) for n in range(0,19)])\n```\n\n### XREF ###\nCf. A008302, A098749.\n\n\n\n## Concatenation of the interim digits in the Michael Damm error detecting algorithm applied to n. ##\n\n### DATA ###\n`0, 3, 1, 7, 5, 9, 8, 6, 4, 2, 31, 37, 35, 30, 39, 38, 33, 34, 32, 36, 17, 10, 19, 12, 11, 15, 14, 18, 16, 13, 78, 79, 74, 75, 73, 76, 72, 70, 71, 77, 53, 56, 57, 54, 52, 50, 59, 55, 58, 51, 92, 95, 98, 91, 94, 93, 96, 97, 99, 90, 89, 84, 83, 88, 86, 81, 87, 82`\n\n### OFFSET ###\n0\n\n### COMMENTS ###\nLast digit in a(n) is A375584(m).\n\n### LINKS ###\nH. Michael Damm, \u003ca href=\"https://doi.org/10.1016/j.disc.2006.05.033\"\u003eTotally anti-symmetric quasigroups for all orders n not equal to 2 or 6\u003c/a\u003e, Discrete Math., 307:6 (2007), 715-729.\n\nWikipedia, \u003ca href=\"https://en.wikipedia.org/wiki/Damm_algorithm\"\u003eDamm algorithm\u003c/a\u003e.\n\n### PROG ###\n```\n(Python)\nt = [\n    [0, 3, 1, 7, 5, 9, 8, 6, 4, 2],\n    [7, 0, 9, 2, 1, 5, 4, 8, 6, 3],\n    [4, 2, 0, 6, 8, 7, 1, 3, 5, 9],\n    [1, 7, 5, 0, 9, 8, 3, 4, 2, 6],\n    [6, 1, 2, 3, 0, 4, 5, 9, 7, 8],\n    [3, 6, 7, 4, 2, 0, 9, 5, 8, 1],\n    [5, 8, 6, 9, 7, 2, 0, 1, 3, 4],\n    [8, 9, 4, 5, 3, 6, 2, 0, 1, 7],\n    [9, 4, 3, 8, 6, 1, 7, 2, 0, 5],\n    [2, 5, 8, 1, 4, 3, 6, 7, 9, 0]\n]\ndef a(n):\n    i,r,s = 0,0,str(n)\n    x = len(s)-1\n    for d in s:\n        i = t[i][int(d)]\n        r += i * (10 ** x)\n        x -= 1\n    return r\nprint([a(n) for n in range(0, 68)])\n```\n\n### XREF ###\nCf. A375584.\n\n### KEYWORD ###\nbase\n\n\n\n## In the non-adjacent form of n, increment each digit by one then convert to base 10 from base 3. ##\n\n### DATA ###\n`0, 1, 7, 21, 22, 23, 64, 66, 67, 68, 70, 192, 193, 194, 199, 201, 202, 203, 205, 210, 211, 212, 577, 579, 580, 581, 583, 597, 598, 599, 604, 606, 607, 608, 610, 615, 616, 617, 631, 633, 634, 635, 637, 1731, 1732, 1733, 1738, 1740, 1741, 1742, 1744, 1749, 1750, 1751, 1792, 1794, 1795, 1796, 1798, 1812, 1813, 1814, 1819, 1821, 1822, 1823, 1825, 1830`\n\n### OFFSET ###\n0\n\n### LINK ###\nWikipedia, \u003ca href=\"https://en.wikipedia.org/wiki/Non-adjacent_form\"\u003eNon-adjacent form\u003c/a\u003e.\n\n### PROG ###\n```\n(Python)\ndef g(n):\n    if n \u003c 2: return n\n    E, Z, tmp = n, [], \"\"\n    while E:\n        Zi = 0\n        if E \u0026 1:\n            Zi = 2 - (E \u0026 3)\n            E -= Zi\n        tmp = str(Zi+1) + tmp\n        E \u003e\u003e= 1\n    return int(tmp,3)\nprint([g(n) for n in range(0,68)])\n```\n\n### KEYWORD ###\nbase\n\n### XREF ###\nCf. A030190, A379015.\n\n\n\n## Concatenation of remainders n mod p, over all primes p \u003c n in largest prime to smallest prime order for n \u003e 2 else 0. ##\n\n### DATA ###\n`0, 0, 10, 100, 210, 1000, 2110, 13200, 24010, 30100, 41210, 152000, 263110, 1304200, 2410010, 3521100, 4632210, 15743000, 26854110, 137960200, 2481001010, 359012100, 4610123210, 15711234000, 26812340110, 3790451200, 48101562010, 59112603100, 610123714210, 1711134820000`\n\n### OFFSET ###\n1\n\n### PROG ###\n```\n(Python)\nfrom sympy import primerange\ndef a(n):\n  s = \"0\"\n  for p in primerange(0, n):\n    s = str(n % p) + s\n  return int(s)\nprint([a(n) for n in range(3,31)])\n```\n\n### XREF ###\nCf. A024934.\n\n\n\n## Integer encoding of the Huffman-reverse-binary of digit frequency PROGs from a string concatenated 0 through n-1 in hex. ##\n\n### DATA ###\n`0, 2, 28, 228, 4004, 64196, 1027176, 16434824, 534431368, 17103505032, 547312453256, 17513998550664, 560447953628296, 17934334516106504, 573898704515408272, 18364758544493064720, 15905192667998458110, 32091890336705087591, 294840779328134333229, 294840779309540717289`\n\n### OFFSET ###\n1\n\n### COMMENTS ###\n```\nThe huffman resulting PROGs are agnostic to the order of concatenation, It could be 0..(n-1) or (n-1)..0.\nConcatenate the hex digits of all numbers from 0 to n-1 into a string, compute the digit frequencies, construct a Huffman PROG using these frequencies, reverse the binary PROGs for each digit (in order of increasing digit), concatenate these reversed PROGs, and interpret the result as a binary number.\n```\n\n### LINKS ###\nWikipedia, \u003ca href=\"https://en.wikipedia.org/wiki/Huffman_coding\"\u003eHuffman coding\u003c/a\u003e.\n\n### EXAMPLE ###\n```\nFor n = 5, a(5) = 4004 because:\n'01234' has a the following Huffman coding: {'2':'00','3':'01','4':'10','0':'110','1':'111'},\nand the reversed and concatenated PROGs: '111110100100_2 = 4004.\n```\n\n### PROG ###\n```\n(Python)\nfrom heapq import heappush, heappop, heapify\nfrom collections import defaultdict\ndef enPROG(S):\n    if len(S) \u003c 2: return [(s, '0') for s in S]\n    h = [[w, [s, \"\"]] for s, w in S.items()]\n    heapify(h)\n    while len(h) \u003e 1:\n        lo, hi = heappop(h), heappop(h)\n        for p in lo[1:]: p[1] = '0' + p[1]\n        for p in hi[1:]: p[1] = '1' + p[1]\n        heappush(h, [lo[0] + hi[0]] + lo[1:] + hi[1:])\n    return sorted(heappop(h)[1:], key=lambda p: (len(p[-1]), p))\ndef a(n):\n    t = \"\".join([hex(x)[2:] for x in range(0,n)])\n    s = defaultdict(int)\n    for c in t: s[c] += 1\n    return int(\"\".join([p[1] for p in enPROG(s)][::-1]),2)\nprint([a(n) for n in range(1,21)])\n```\n\n### KEYWORD ###\nbase\n\n\n\n## The Hamming(7,4) error-correcting PROG encoding of n. ##\n\n### DATA ###\n`0, 7, 28, 15, 56, 45, 30, 11, 112, 25, 90, 51, 60, 85, 22, 127, 448, 195, 100, 359, 360, 107, 204, 463, 240, 499, 340, 87, 88, 347, 508, 255, 896, 645, 390, 131, 200, 461, 718, 971, 720, 981, 214, 467, 408, 157, 926, 667, 480, 229, 998, 739, 680, 941, 174, 427, 176, 437, 694`\n\n### COMMENTS ###\n```\nThis is essentialy Hamming(7,4) with leading zeros omitted.\na(n) always has an even number of bits set.\n```\n\n### LINKS ###\nWikipedia, \u003ca href=\"https://en.wikipedia.org/wiki/Hamming_PROG\"\u003eHamming PROG\u003c/a\u003e.\n\n### OFFSET ###\n0\n\n### EXAMPLE ###\n```\nFor n = 11, a(11) = 51 because 11 = 1011_2 and\nfloor(log2(11)) + 1 = 4 and\np = 3 such that 2^3 \u003e= 4 + 3 + 1, p = A320065(n+4), and PROGword = 3+4=7.\nPositions:   1 2 3 4 5 6 7\nData:        ? ? 1 ? 0 1 1\nbits set:  3,6,7 and 3 XOR 6 XOR 7 = 2 or 010_2 and\nfill parity bits 1,2,4 with Ones\nPositions:   1 2 3 4 5 6 7\nParity bits: 0 1 1 0 0 1 1 (total XOR is 0) and\n0110011_2 is 51.\n```\n\n### FORMULA ###\n```\na(2^k) 7*(2^A324540(k+1)) NO!!!!\na(2^k) = 0 (mod 7).\n```\n\n### PROG ###\n```\n(Python)\ndef a(n):\n    if n == 0: return 0\n    p, l = 0, n.bit_length()\n    while (1 \u003c\u003c p) \u003c (l + p + 1): p += 1\n    tl, k, ix, cw = l+p, l-1, 0, 0\n    for i in range(1, tl + 1):\n        if (i \u0026 (i - 1)):\n            v = (n \u0026 (1 \u003c\u003c k)) \u003e\u003e k\n            k -= 1\n            cw += (v \u003c\u003c (tl-i))\n            if v == 1: ix ^= i\n    for i in range(p):\n        cw += ((ix \u003e\u003e i) \u0026 1) \u003c\u003c (tl-(1 \u003c\u003c i))\n    return cw\nprint([a(n) for n in range(0, 59)])\n```\n\n### KEYWORD ###\nbase\n\n### XREF ###\nCf. A000079, A070939, A320065.\n\n\n\n## Number of calls to Karatsuba's multiplication algorithm K(x,y) when recursively calculating K(Fibonacci(n),Fibonacci(n+1)) in binary digits. ##\n\n### DATA ###\n`1, 1, 1, 1, 1, 1, 4, 4, 4, 7, 4, 4, 10, 10, 10, 13, 13, 13, 16, 22, 22, 28, 22, 25, 25, 25, 34, 37, 34, 37, 37, 40, 43, 40, 49, 49, 52, 61, 58, 64, 70, 64, 67, 67, 70, 76, 79, 85, 73, 100, 88, 88, 97, 94, 91, 106, 100, 106, 106, 115, 112, 112, 97, 118, 142`\n\n### OFFSET ###\n1\n\n### COMMENTS ###\n```\nWhen x and y are both 2 or more digits and the larger is L digits long, base b = 2^floor(L/2) is chosen as a split point for those digits with x = xhi*b + xlo and y = yhi*b + ylo.\nK(x,y) then makes 3 recursive calls to K(xhi,yhi), K(xlo,ylo) and K(xhi+xlo,yhi+ylo) (and those results can be assembled to make product x*y).\nThe initial K call and all further recursive calls are counted in a(n).\n1 initial call and then 3 recursive calls each time means a(n) == 1 (mod 3).\n```\n\n### LINKS ###\nWikipedia, \u003ca href=\"https://en.wikipedia.org/wiki/Karatsuba_algorithm\"\u003eKaratsuba algorithm\u003c/a\u003e.\n\n### PROG ###\n```\n(Python) \ncounter = 0\ndef K(x: int, y: int) -\u003e int:\n    global counter; counter += 1\n    if x \u003c 10 or y \u003c 10: return x * y\n    digits = max(len(bin(x)[2:]), len(bin(y)[2:])) \u003e\u003e 1\n    base = 1 \u003c\u003c digits\n    b1 = base-1\n    a,b = x \u003e\u003e digits, x \u0026 b1\n    c,d = y \u003e\u003e digits, y \u0026 b1\n    x = K(b, d)\n    y = K(a + b, c + d)\n    z = K(a, c)\n    return z * (1 \u003c\u003c (digits \u003c\u003c 1)) + (y - z - x) * base + x\ndef a(n: int) -\u003e int:\n    from sympy import fibonacci\n    global counter; counter = 0\n    K(fibonacci(n), fibonacci(n + 1))\n    return counter\nprint([a(n) for n in range(1, 66)])\n```\n\n### XREF ###\nCf. A379740.\n\n### KEYWORD ###\nbase\n\n\n\n## Integer encoding of the Huffman-reverse-binary of digit frequency PROGs from a string concatenated 0 through n-1. ##\n\n### DATA ###\n`0, 2, 28, 228, 4004, 64196, 1027176, 16434824, 534431368, 17103505032, 17103430188, 34206888202, 25044430919, 25044431395, 22753794595, 20463342115, 548981675858, 549180765488, 532537767216, 549180765488, 25044430919, 25044430919, 45507564723, 40926268323, 36345002643`\n\n### OFFSET ###\n1\n\n### COMMENTS ###\n```\nThe huffman resulting PROGs are agnostic to the order of concatenation, It could be 0..(n-1) or (n-1)..0.\nConcatenate the digits of all numbers from 0 to n-1 into a string, compute the digit frequencies, construct a Huffman PROG using these frequencies, reverse the binary PROGs for each digit (in order of increasing digit), concatenate these reversed PROGs, and interpret the result as a binary number.\n```\n\n### LINKS ###\nWikipedia, \u003ca href=\"https://en.wikipedia.org/wiki/Huffman_coding\"\u003eHuffman coding\u003c/a\u003e.\n\n### EXAMPLE ###\n```\nFor n = 5, a(5) = 4004 because:\n'01234' has a the following Huffman coding: {'2':'00','3':'01','4':'10','0':'110','1':'111'},\nand the reversed and concatenated PROGs: '111110100100_2 = 4004.\n```\n\n### PROG ###\n```\n(Python)\nfrom heapq import heappush, heappop, heapify\nfrom collections import defaultdict\ndef enPROG(S):\n    if len(S) \u003c 2: return [(s, '0') for s in S]\n    h = [[w, [s, \"\"]] for s, w in S.items()]\n    heapify(h)\n    while len(h) \u003e 1:\n        lo, hi = heappop(h), heappop(h)\n        for p in lo[1:]: p[1] = '0' + p[1]\n        for p in hi[1:]: p[1] = '1' + p[1]\n        heappush(h, [lo[0] + hi[0]] + lo[1:] + hi[1:])\n    return sorted(heappop(h)[1:], key=lambda p: (len(p[-1]), p))\ndef a(n):\n    t = \"\".join([str(x) for x in range(0,n)])\n    s = defaultdict(int)\n    for c in t: s[c] += 1\n    return int(\"\".join([p[1] for p in enPROG(s)][::-1]),2)\nprint([a(n) for n in range(1,26)])\n```\n\n### KEYWORD ###\nbase\n\n\n\n## Partial products of A217793. ##\n\n### DATA ###\n`91, 368016, 7704998400, 154254553560616860000, 81099490326469519642214400, 123904409109840398901842327944396800000, 312980442261030492019371810265757601600000000, 7086288143652192493789225352443309285162175220940800000000, 14310712231229003211358115874216631351811959497046688833146971817246720000000000`\n\n### COMMENTS ###\n```\nIn October of 1941 Paul Erdős and Pál Turán found that a Golomb ruler could be constructed for every odd prime p.\nSuch a ruler has the property that the mark or notches are defined by: notch(k) = 2pk + (k^2 mod p) for k in {0..p-1}, with p=A000040(n).\n```\n\n### FORMULA ###\n`a(n) = Product_{k=1..p-1} (2*k*p + (k^2 mod p)), where p is the n-th prime.`\n\n### OFFSET ###\n2\n\n### PROG ###\n```\n(Python)\nfrom sympy import prod, prime\ndef a(n):\n  p = prime(n)\n  return prod(2*p*k + pow(k,2,p) for k in range(1, p))\nprint([a(n) for n in range(2, 11)])\n```\n\n### XREF ###\nCf. A000040, A217793, A380790.\n\n\n\n## Numbers that can be written in only one way in the form (j+2k)^2-(j+k)^2-j^2 with j,k\u003e0. ##\n\n### DATA ###\n3, 4, 7, 11, 12, 16, 19, 20, 23, 28, 31, 43, 44, 47, 48, 52, 59, 67, 68, 71, 76, 79, 80, 83, 92, 103, 107, 112, 116, 124, 127, 131, 139, 148, 151, 163, 164, 167, 172, 176, 179, 188, 191, 199, 208, 211, 212, 223, 227, 236, 239, 244, 251, 263, 268, 271, 272, 283\n\n### OFFSET ###\n1\n\n### LINK ###\nProject Euler, \u003ca href=\"https://projecteuler.net/problem=135\"\u003eProblem 135: Same Differences\u003c/a\u003e.\n\n### COMMENTS ###\n```\nThese numbers have a pair of divisors p,q that sum to a multiple of 4.\nNumbers congruent {0, 3, 4, 7, 11, 12, 15} mod 16.\nAlso numbers that can be written in only one way in the form (j+k)*(3k-j) for j,k\u003e0.\n```\n\n### PROG ###\n```\n(Python)\nfrom sympy import divisors\ndef isok(n):\n  s = 0\n  for d in divisors(n):\n    t = n // d + d\n    if ((q:=t \u003e\u003e 2) \u003c\u003c 2) == t and q \u003c d:\n      s += 1\n  return s == 1\nprint([n for n in range(1, 284) if isok(n)])\n```\n\n### XREF ###\nCf. A364168, A383252.\n\n\n\n## Numbers that can be written in the form (j+2k)^2-(j+k)^2-j^2 with j,k\u003e0. ##\n\n### DATA ###\n`3, 4, 7, 11, 12, 15, 16, 19, 20, 23, 27, 28, 31, 32, 35, 36, 39, 43, 44, 47, 48, 51, 52, 55, 59, 60, 63, 64, 67, 68, 71, 75, 76, 79, 80, 83, 84, 87, 91, 92, 95, 96, 99, 100, 103, 107, 108, 111, 112, 115, 116, 119, 123, 124, 127, 128, 131, 132, 135, 139, 140`\n\n### OFFSET ###\n1\n\n### LINK ###\nProject Euler, \u003ca href=\"https://projecteuler.net/problem=135\"\u003eProblem 135: Same Differences\u003c/a\u003e.\n\n### COMMENTS ###\n```\nThese numbers have a pair of divisors p,q that sum to a multiple of 4.\nNumbers congruent {0, 3, 4, 7, 11, 12, 15} mod 16.\nAlso numbers that can be written in the form (j+k)*(3k-j) for j,k\u003e0.\n```\n\n### PROG ###\n```\n(Python)\nfrom sympy import divisors\ndef isok(n):\n  D = divisors(n)\n  L = len(D)\n  for i in range((L \u003e\u003e 1) + 1):\n    p,q = D[i], D[L-i-1]\n    if ((p+q) \u0026 3 == 0) and (p \u003c= q):\n      return True\n  return False\nprint([n for n in range(1,141) if isok(n)])\n```\n\n### XREF ###\nCf. A364168, A383252.\n\n\n\n## a(n) is the minimum bucket size in a bucket sort algorithm with input {0, 1, ..., n-1} and floor(sqrt(n)) buckets. ##\n\n### DATA ###\n`1, 2, 3, 2, 2, 3, 3, 4, 3, 2, 3, 4, 3, 4, 5, 4, 2, 3, 4, 5, 3, 4, 5, 6, 5, 2, 3, 4, 5, 6, 3, 4, 5, 6, 7, 6, 2, 3, 4, 5, 6, 7, 3, 4, 5, 6, 7, 8, 7, 2, 3, 4, 5, 6, 7, 8, 3, 4, 5, 6, 7, 8, 9, 8, 2, 3, 4, 5, 6, 7, 8, 9, 3, 4, 5, 6, 7, 8, 9, 10, 9, 2, 3, 4`\n\n### COMMENTS ###\nThe maximum and minimum bucket size are equal when n is in A006446.\n\n### FORMULA ###\n`a(n) = min(floor((n-1)/sqrt(n))+1, n mod (floor((n-1)/sqrt(n))+1)).`\n\n### OFFSET ###\n1\n\n### EXAMPLE ###\n```\nFor n = 10 a(10) = 4 because:\nInput array: [0,1,2,3,4,5,6,7,8,9] and floor(sqrt(10)) = 3.\nResulting 3 buckets of [0, 1, 2, 3], [4, 5, 6, 7], [8, 9] and the length of the buckets [4,4,2].\nThe minimum bucket size is 2.\n```\n\n### PROG ###\n```\n(Python)\nfrom sympy.core.intfunc import isqrt\ndef a(n):\n    bc = isqrt(n)\n    bs = ((n-1) // bc) + 1\n    fb,r = divmod(n,bs)\n    return min(bs, r) if r \u003e 0 else bs\nprint([a(n) for n in range(1,85)])\n```\n\n### XREF ###\nCf. A000079, A000196, A006446.\n\n\n\n## The lexicographic rank of the permutation obtained by recording the swaps needed to sort the Eytzinger permutation of [0, 1, ..., n-1] with the bitonic sorter algorithm. ##\n\n### DATA ###\n`1, 20, 37610, 20246977580570, 258952989957427698229458143957804570, 125887757413908728356528535566203146374133193857422387130710461384133774303059413717804570, 384108221355416548242103320084870428383288373093396696247459149225011268451060632674249034983367221167680047201563521138868562742195457949673151148273338742934440997616360245085791817113232421743299551059413717804570`\n\n### OFFSET ###\n1\n\n### COMMENTS ###\n```\nThe Eytzinger array layout (A375825) arranges elements so that a binary search can be performed starting at element k=1 and at a given k step to 2*k or 2*k+1 according as the target is smaller or larger than the element at k.\nThe lexicographic rank of a permutation of n elements is its position in the ordered list of all possible permutations of n elements, and here taking the first permutation as rank 0.\n```\n\n### LINKS ###\ngeeksforgeeks.org, \u003ca href=\"https://www.geeksforgeeks.org/lexicographic-rank-string-duplicate-characters\"\u003eLexicographic rank of a String\u003c/a\u003e.\n\nSergey Slotin, \u003ca href=\"https://algorithmica.org/en/eytzinger\"\u003eEytzinger binary search\u003c/a\u003e.\n\nsympy.org, \u003ca href=\"https://docs.sympy.org/latest/modules/combinatorics/permutations.html#sympy.combinatorics.permutations.Permutation.rank\"\u003ePermutation rank\u003c/a\u003e.\n\nWikipedia, \u003ca href=\"https://en.wikipedia.org/wiki/bitonic_sorter\"\u003ebitonic sort\u003c/a\u003e.\n\n### PROG ###\n```\n(Python)\nfrom sympy.combinatorics import Permutation\ndef s(arr):\n    n = len(arr)\n    R = list(range(n))\n    k = 2\n    while k \u003c= n:\n        j = k \u003e\u003e 1\n        while j \u003e 0:\n            for i in range(n):\n                if i \u0026 j == 0:\n                    l = i ^ j\n                #if l \u003e i:\n                    if ((i \u0026 k) == 0 and arr[i] \u003e arr[l]) or ((i \u0026 k) != 0 and arr[i] \u003c arr[l]):\n                        arr[i], arr[l] = arr[l], arr[i]\n                        R[i], R[l] = R[l], R[i]\n            j \u003e\u003e= 1\n        k \u003c\u003c= 1\n    return R\ndef eytzinger(t, k=1, i=0):\n    if (k \u003c len(t)):\n        i = eytzinger(t, k * 2, i)\n        t[k] = i\n        i += 1\n        i = eytzinger(t, k * 2 + 1, i)\n    return i\ndef a(n):\n    def eytzinger(t, k=1, i=0):\n        if (k \u003c len(t)):\n            i = eytzinger(t, k * 2, i)\n            t[k] = i\n            i += 1\n            i = eytzinger(t, k * 2 + 1, i)\n        return i\n    t = [0] * ((1 \u003c\u003c n) + 1 )\n    eytzinger(t)\n    return Permutation(s(t[1:])).rank()\nprint([a(n) for n in range(1,8)])\n```\n\n### XREF ###\nCf. A030298, A369802, A370006, A375825, A368783.\n\n\n\n## The lexicographic rank of the permutation obtained by recording the swaps needed to sort the Eytzinger permutation of [0, 1, ..., n-1] with the Bubble sort algorithm. ##\n\n### DATA ###\n`0, 1, 2, 20, 82, 397, 2330, 37610, 301850, 2692730, 26741138, 292548740, 3495111922, 45271195597, 631862060570, 20246977580570, 324237678994970, 5500423810911770, 98823436151007770, 1874553112933484570, 37436027019862950170, 785121450483596287130, 17252158693640677392410, 396372452178749756086250`\n\n### OFFSET ###\n1\n\n### COMMENTS ###\n```\nThe Eytzinger array layout (A375825) arranges elements so that a binary search can be performed starting at element k=1 and at a given k step to 2*k or 2*k+1 according as the target is smaller or larger than the element at k.\nThe lexicographic rank of a permutation of n elements is its position in the ordered list of all possible permutations of n elements, and here taking the first permutation as rank 0.\n```\n\n### LINKS ###\ngeeksforgeeks.org, \u003ca href=\"https://www.geeksforgeeks.org/lexicographic-rank-string-duplicate-characters\"\u003eLexicographic rank of a String\u003c/a\u003e.\n\nSergey Slotin, \u003ca href=\"https://algorithmica.org/en/eytzinger\"\u003eEytzinger binary search\u003c/a\u003e.\n\nsympy.org, \u003ca href=\"https://docs.sympy.org/latest/modules/combinatorics/permutations.html#sympy.combinatorics.permutations.Permutation.rank\"\u003ePermutation rank\u003c/a\u003e.\n\nWikipedia, \u003ca href=\"https://en.wikipedia.org/wiki/Bubble_sort\"\u003eBubble sort\u003c/a\u003e.\n\n### PROG ###\n```\n(Python)\nfrom sympy.combinatorics import Permutation\ndef s(arr):\n    n = len(arr)\n    R = list(range(n))\n    for i in range(n):\n        for j in range(0, n-i-1):\n            if arr[j] \u003e arr[j+1]:\n                arr[j], arr[j+1] = arr[j+1], arr[j]\n                R[j], R[j+1] = R[j+1], R[j]\n    return R\ndef eytzinger(t, k=1, i=0):\n    if (k \u003c len(t)):\n        i = eytzinger(t, k * 2, i)\n        t[k] = i\n        i += 1\n        i = eytzinger(t, k * 2 + 1, i)\n    return i\ndef a(n):\n    t = [0] * (n+1)\n    eytzinger(t)\n    return Permutation(s(t[1:])).rank()\nprint([a(n) for n in range(1,25)])\n```\n\n### XREF ###\nCf. A030298, A369802, A370006, A375825, A368783.\n\n\n\n## The binary expansion of a(n) tracks where the swaps occur to sort the binary expansion of n. ##\n\n### DATA ###\n`0, 2, 0, 10, 8, 4, 0, 74, 72, 68, 64, 36, 32, 16, 0, 1098, 1096, 1092, 1088, 1060, 1056, 1040, 1024, 548, 544, 528, 512, 272, 256, 128, 0, 33866, 33864, 33860, 33856, 33828, 33824, 33808, 33792, 33316, 33312, 33296, 33280, 33040, 33024, 32896, 32768, 16932, 16928`\n\n### COMMENTS ###\n```\nLeading zeros are ommitted in the resulting encoding.\nThe number of left shifts for a(n) is A000217(floor(log_2(n))+1).\n```\n\n### EXAMPLE ###\n```\nFor n = 22, a(22) = 1040 because:\n22 is 10110_2 and\n i | j | B[i] | B[j] | Encoding\n---+---+------+------+----------\n 0 | 1 | 1    | 0    | 1\n 0 | 2 | 0    | 1    | 0\n 0 | 3 | 0    | 1    | 0\n 0 | 4 | 0    | 0    | 0\n 1 | 2 | 1    | 1    | 0\n 1 | 3 | 1    | 1    | 0\n 1 | 4 | 1    | 0    | 1\n 2 | 3 | 1    | 1    | 0\n 2 | 4 | 1    | 1    | 0\n 3 | 4 | 1    | 1    | 0\n10110_2 sorted is 00111_2.\nAnd a(n) = 1000 001 00 0 = 1040.\n       i =    0   1  2 3\n```\n\n### FORMULA ###\n`a(2^k) = Sum_{j=1..k-1} 2^((j^2 + 3j - 4)/2 + 3) + 2.`\n\n### PROG ###\n```\n(Python)\ndef a(n):\n    c, B, lb = 0, list(map(int, bin(n)[2:])), n.bit_length()\n    for i in range(lb):\n        for j in range(i+1, lb):\n            if B[i] \u003e B[j]:\n                B[i],B[j] = B[j],B[i]\n                c |=1\n            c \u003c\u003c= 1\n    return c\nprint([a(n) for n in range(1,50)])\n```\n\n### XREF ###\nCf. A000079, A000217, A006125, A070939, A380145.\n\n### KEYWORD ###\nbase\n\n\n\n## Binary left shift XOR sum of n. ##\n\n### DATA ###\n`1, 6, 5, 28, 27, 18, 21, 120, 119, 102, 105, 68, 75, 90, 85, 496, 495, 462, 465, 396, 403, 434, 429, 264, 279, 310, 297, 372, 363, 330, 341, 2016, 2015, 1950, 1953, 1820, 1827, 1890, 1885, 1560, 1575, 1638, 1625, 1764, 1755, 1690, 1701, 1040, 1071, 1134`\n\n### FORMULA ###\n```\na(2^k+1) = a(2^k) - 1 for k\u003e2.\na(2^k) = A006516(k-1).\n```\n\n### EXAMPLE ###\n```\nfor n = 6 a(6)= 18 because 6 in base 2 is 110\nand:\n  110\n 110\n110\n------\n10010\nand 10010 in base 10 is 18\n```\n\n### PROG ###\n```\n(Python)\ndef a(n):\n    if (n \u003e 2) and (n - 1) \u0026 (n - 2) == 0: return a(n-1)-1\n    m = n\n    r = n\n    for i in range(0, n.bit_length()-1):\n        m \u003c\u003c= 1\n        r ^= m\n    return r\nprint([a(n) for n in range(1, 51)])\n```\n\n### keyword ###\nbase\n\n### XREF ###\nCf. A000051, A000079, A006516, A378299.\n\n\n\n## Lexicographic rank of the bit-reversal permutation of elements {0, 1, ..., 2^n - 1}. ##\n\n### DATA ###\n`0, 0, 2, 2354, 633303178034, 4047127158317611833545968021642034, 983558374988244870572855228078991302744595248608705829863205162000316468367968661642034`\n\n### COMMENTS ###\nAlso the inversion count of the bit reversal permutation of elements {0, 1, ..., 2^n - 1} is A100575(n).\n\n### EXAMPLE ###\n```\n| n | 2^n | Sequence                                              | rank\n+---+-----+-------------------------------------------------------+--------------\n| 0 | 1   | 0                                                     | 0\n| 1 | 2   | 0, 1                                                  | 0\n| 2 | 4   | 0, 2, 1, 3                                            | 2\n| 3 | 8   | 0, 4, 2, 6, 1, 5, 3, 7                                | 2354\n| 4 | 16  | 0, 8, 4, 12, 2, 10, 6, 14, 1, 9, 5, 13, 3, 11, 7, 15  | 633303178034\n```\n\n### LINK ###\nWikipedia, \u003ca href=\"https://en.m.wikipedia.org/wiki/Bit-reversal_permutation\"\u003eBit-reversal_permutation\u003c/a\u003e.\n\n### PROG ###\n```\n(Python)\nfrom sympy.combinatorics import Permutation\ndef a(n):\n    p = [0]\n    for _ in range(n):\n        p = [x \u003c\u003c 1 for x in p] + [(x \u003c\u003c 1) + 1 for x in p]\n    return Permutation(p).rank()\nprint([a(n) for n in range(0,8)])\n```\n\n### XREF ###\nCf. A000079, A100575.\n\n## GCR(0,2) RLL encoding of n. ##\n\n### DATA ###\n`25, 27, 18, 19, 889, 891, 882, 883, 601, 603, 594, 595, 633, 635, 626, 627, 28473, 28475, 28466, 28467, 28537, 28539, 28530, 28531, 28249, 28251, 28242, 28243, 28281, 28283, 28274, 28275, 19257, 19259, 19250, 19251, 19321, 19323, 19314, 19315, 19033, 19035, 19026, 19027, 19065, 19067, 19058, 19059, 20281, 20283, 20274, 20275, 20345, 20347, 20338, 20339, 20057, 20059, 20050, 20051, 20089, 20091, 20082`\n\n### COMMENTS ###\nGCR(0,2) RLL encoding of n but with leading zeros ignored.\n\n### OFFSET ###\n0\n\n### FORMULA ###\n```\na(n) = a(n-1) + 2 for n = 1 mod 4.\na(n) = a(n-1) + 1 for n = 3 mod 4.\n```\n\n### LINK ###\nWikipedia, \u003ca href=\"https://en.wikipedia.org/wiki/Run-length_limited\"\u003eRun-length limited\u003c/a\u003e.\n\n### PROG ###\n```\n(Python)\ndef tobase4(n):\n    if n == 0: return [0]\n    d = []\n    while n \u003e 0:\n        d.append(n \u0026 3)\n        n \u003e\u003e= 2\n    return d[::-1]\ndef a(n):\n    if n \u0026 1:\n        if n \u0026 3 == 1: return a(n-1) + 2\n        if n \u0026 3 == 3: return a(n-1) + 1\n    enc_map = {\n         '0': '11001',\n         '1': '11011',\n         '2': '10010',\n         '3': '10011',\n        '10': '11101',\n        '11': '10101',\n        '12': '10110',\n        '13': '10111',\n        '20': '11010',\n        '21': '01001',\n        '22': '01010',\n        '23': '01011',\n        '30': '11110',\n        '31': '01101',\n        '32': '01110',\n        '33': '01111'\n    }\n    return int(\"\".join(enc_map[str(b)] for b in tobase4(n)),2)\nprint([a(n) for n in range(0, 63)])\n```\n\n### KEYWORD ###\nbase, easy\n\n\n\n## Determinant for a Matrix M where M[i,j] = i*j for n \u003e= i \u003e j \u003e= 1 and 1 for 1 \u003c= i \u003c j \u003c= n. ##\n\n### DATA ###\n`1, 2, 15, 220, 5225, 181830, 8697535, 546702200, 43667838225, 4318264002250, 517759853869775, 73992590025753300, 12424589075157741625, 2421839132034593636750, 542318977066317932229375, 138255184553439984856342000, 39808852202356125639572974625, 12855917564172654691838566511250`\n\n### OFFSET ###\n1\n\n### COMMENTS ###\nConversely the determinant for a Matrix M where M[i,j] = i*j for n \u003e= i \u003c j \u003e= 1 and 1 for 1 \u003c= i \u003e j \u003c= n is A130031.\n\n### PROG ###\n```\n(Python)\nfrom sympy import Matrix\ndef a(n):\n  M=[]\n  for i in range(1,n+1):\n    row = []\n    for j in range(1, i + 1):\n      row.append(i*j)\n    for j in range(i+1, n+1):\n      row.append(1)\n    M.append(row)\n  return Matrix(M).det()\nprint([a(n) for n in range(1,19)])\n```\n\n### XREF ###\nCf. A130031.\n\n\n\n## a(n) is the binary representation of all partitions of n concatenated together and then converted back to an integer. ##\n\n### DATA ### \n`1, 14, 247, 257724, 1065025357, 35885265650137438, 38609324441197878878632815, 2784857543866383669141335397168626591038200, 3289398245348065727050918124067161877654368252646454686822432025, 34167438679741495089595242316096683785231545331043085651352870101508863522845099586771564396397882`\n\n### OFFSET ### \n1\n\n### PROG ###\n```\n(Python)\ndef partitions(n):\n    s = [(n, n, [])]\n    while s:\n        r, m, c = s.pop()\n        if r == 0:\n            yield c\n            continue\n        for i in range(min(r, m), 0, -1):\n            s.append((r - i, i, c + [i]))\ndef a(n):\n    tmp = \"\"\n    for p in partitions(n):\n        tmp += \"\".join([bin(x)[2:] for x in p])\n    return int(tmp, 2)\nprint([a(n) for n in range(1,11)])\n```\n\n### KEYWORD ###\nbase\n\n\n\n## a(0) = 0 and a(n) is binomial(n, a(n - 1)) + 1 ##\n\n### DATA ###\n`0, 2, 2, 4, 2, 11, 1, 8, 2, 37, 1, 12, 2, 79, 1, 16, 2, 137, 1, 20, 2, 211, 1, 24, 2, 301, 1, 28, 2, 407, 1, 32, 2, 529, 1, 36, 2, 667, 1, 40, 2, 821, 1, 44, 2, 991, 1, 48, 2, 1177, 1, 52, 2, 1379, 1, 56, 2, 1597, 1, 60, 2, 1831, 1, 64, 2, 2081, 1, 68, 2, 2347, 1, 72, 2, 2629, 1, 76`\n\n\n### FORMULA ###\n```\na(A016825(n)) = 1.\na(A019442(n)) = 2.\na(A000225(n)) = 2^n.\na(A016813(n)) = A188135(floor(n/4)) for n \u003e 0.\na(A016754(n)) = 1 + 2n + 10n^2 + 16n^3 + 8n^4 if n \u003e 0.\na(n) = (gamma(n+1) / gamma(n-a(n-1)+1) * gamma(a(n-1)+1)) + 1.\n```\n\n### OFFSET ###\n0\n\n### PROG ###\n```\n(Python)\nfrom sympy import binomial\ndef a(n):\n  if n == 0: return 0\n  return binomial(n, a(n - 1)) + 1\nprint([a(n) for n in range(0,76)])\n```\n\n### XREF ### \nCf. A000142, A000225, A016825, A019442, A188135, A016813.\n\n\n\n## a(n) is the product of antidivisors of the totient of n. ##\n\n### DATA ###\n`1, 1, 3, 1, 4, 3, 4, 3, 84, 3, 40, 4, 15, 15, 33, 4, 1680, 15, 40, 84, 8100, 15, 312, 40, 1680, 40, 25080, 15, 960, 33, 312, 33, 112, 40, 192, 1680, 112, 33, 11664, 40, 114240, 312, 112, 8100, 33852, 33, 114240, 312, 257985, 112, 9261000, 1680, 11664, 112, 192, 25080, 6296940, 33, 10053120, 960, 192, 257985, 3040, 312, 280896, 257985, 696, 112, 315840, 112, 15924480, 192, 11664`\n\n### OFFSET ###\n3\n\n### FORMULA ###\n```\na(n) = Product_{d in antidivisors(totient(n))} d.\na(n) = A091507(A000010(n)).\n```\n\n### CODE ###\n```\n(Python)\nfrom sympy.ntheory.factor_ import antidivisors\nfrom sympy import prod, totient\na = lambda n: prod(antidivisors(totient(n)))\nprint([a(n) for n in range(3, 76)])\n```\n\n### KEYWORD ###\neasy\n\n### XREF ###\nCf. A000010, A091507.\n\n\n\n## Product of the totients of the antidivisors of n. ##\n \n### DATA ###\n`1, 1, 1, 2, 2, 2, 8, 8, 2, 24, 12, 16, 48, 24, 8, 20, 480, 192, 24, 96, 12, 768, 384, 48, 768, 64, 480, 5760, 36, 64, 864, 41472, 960, 88, 1056, 32, 1280, 153600, 1440, 1728, 216, 6144, 3584, 224, 27648, 8640, 4320, 1152, 14400, 38400, 32, 442368, 110592, 96, 2880, 576, 3168, 608256, 331776, 491520, 800, 12800, 69120, 84, 4032, 17280, 17915904, 663552, 44, 17664, 11040, 1720320, 677376, 12096, 1280`\n\n### OFFSET ###\n1\n\n### FORMULA ###\n`a(n) = Product_{d in antidivisors(n)} totient(d).`\n\n### PROG ###\n```\n(Python)\nfrom sympy.ntheory.factor_ import antidivisors\nfrom sympy import prod, totient\na = lambda n: prod(totient(d) for d in antidivisors(n))\nprint([a(n) for n in range(1, 76)])\n```\n\n### XREF ###\nCf. A000010, A091507.\n\n\n\n## a(n) is the cumulative sum of the multiplicative cost of merge in the optimal file merge pattern like algorithm applied to the list comprising 1 to n. ##\n\n### DATA ###\n`0, 2, 8, 32, 148, 784, 5244, 41160, 365196, 3634770, 39939046, 479102742, 6227559458, 87181950308, 1307698387400, 20922911172308, 355687947758520, 6402375473783654, 121645105512067786, 2432902028391283234, 51090942270685982446, 1124000728416448387006, 25852016743979951090832`\n\n### COMMENTS ###\nIn the original version of the optimal file merge pattern the cost is calculated with a sum.\n\n### OFFSET ###\n1\n\n### LINK ###\ngeeksforgeeks.org, \u003ca href=\"https://www.geeksforgeeks.org/optimal-file-merge-patterns/\"\u003eOptimal merge patterns\u003c/a\u003e.\n\n### EXAMPLE ###\n```\nFor n = 5:\nStarting with f=[1,2,3,4,5]:\nlen(f) | f               | t   | c\n      5 | [1, 2, 3, 4, 5] | 2   | 2\n      4 | [2, 3, 4, 5]    | 6   | 8\n      3 | [4, 5, 6]       | 20  | 28\n      2 | [6, 20]         | 120 |148\n a(n) = 2+6+20+120 = 148\n```\n\n### PROG ###\n```\n(Python)\nimport heapq\ndef Omp(f):\n    c = 0\n    heapq.heapify(f)\n    while len(f) \u003e 1:\n        a = heapq.heappop(f)\n        b = heapq.heappop(f)\n        m = a * b\n        c += m\n        heapq.heappush(f, m)\n    return c\na = lambda n: Omp(list(range(1, n+1)))\nprint([a(n) for n in range(1, 24)])\n```\n\n\n\n## a(n) is the multiplicative cost of merge in the optimal merge pattern like algorithm applied to the list comprising 1 to n. ##\n\n### DATA ###\n`1, 2, 12, 288, 28800, 6220800, 6096384000, 14046068736000, 63712967786496000, 573416710078464000000, 15264352822288711680000000, 949564860368936176189440000000, 116826863900910955628939182080000000, 28851562308968969602122820406476800000000, 12853371008645675957745716491085414400000000000`\n\n### COMMENTS ###\n```\nIn the original optimal file merge pattern algorithm: the counter variable c accumulates a sum of each value of t, while in this algorithm is c*= t.\nConversely when c accmuluates a sum of eatch t the resulting sequence is A328950.\nAll the t numbers are congruent to 0 or 1 (mod 3) (A032766).\na(n) is divisible by n!.\n```\n\n### OFFSET ###\n1\n\n### LINK ###\ngeeksforgeeks.org, \u003ca href=\"https://www.geeksforgeeks.org/optimal-file-merge-patterns/\"\u003eOptimal merge patterns\u003c/a\u003e.\n\n### EXAMPLE ###\n```\n For n = 5:\n Starting with f=[1,2,3,4,5]:\n len(f) | f               | m   | c\n      5 | [1, 2, 3, 4, 5] | 2   | 2\n      4 | [2, 3, 4, 5]    | 6   | 12\n      3 | [4, 5, 6]       | 20  | 240\n      2 | [6, 20]         | 120 | 28800\n a(n) = 2*6*20*120 = 28800\n```\n\n### PROG ###\n```\n(Python)\ndef Omp(f):\n    c = 1\n    heapq.heapify(f) \n    while len(f) \u003e 1:\n        a = heapq.heappop(f)  \n        b = heapq.heappop(f)  \n        m = a * b            \n        c *= m                \n        heapq.heappush(f, m) \n    return c\na = lambda n: Omp(list(range(1, n+1)))\nprint([a(n) for n in range(1, 16)])\n```\n\n### XREF ###\nCf. A000120.\n\n\n## How to cite\n\n```\n@misc{clavijo2025myintegersequences,\n  author       = {Darío Clavijo},\n  title        = {MyIntegerSequences: Personal collection of integer sequences},\n  year         = {2025},\n  howpublished = {\\url{https://github.com/daedalus/MyIntegerSequences}},\n  note         = {GitHub repository},\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdaedalus%2Fmyintegersequences","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdaedalus%2Fmyintegersequences","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdaedalus%2Fmyintegersequences/lists"}