cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

Showing 1-2 of 2 results.

A365749 Number of iterations that produce a record high of the digest of the SHA2-256 hash of the empty string.

Original entry on oeis.org

1, 13, 58, 117, 216, 15752, 76392, 3129199, 10886293, 12306717, 61545851, 167927267, 197150851, 212386485, 759678443, 5902809947, 14710854746, 186485968010, 335913058990, 347769614838, 10324357504414, 23560859051696, 76581364219495
Offset: 1

Views

Author

DarĂ­o Clavijo, Sep 17 2023

Keywords

Comments

The SHA2-256 algorithm takes inputs of any length but here we are feeding the output of every iteration to the next.

Examples

			a(1) = 1 because 1 iteration sha256("") = hex e3b0....b855 is taken as greater than the empty string "" starting point.
a(2) = 13 is the next term since 13 times nested sha256(...(sha256("")...)) = hex f761...8338 is greater than the previous record e3b0....b855.
		

Crossrefs

Programs

  • Python
    from itertools import islice
    import hashlib
    def g():
      c, vmax, m = 1, b"", b""
      while True:
        if (m:= hashlib.sha256(m).digest()) > vmax:
          vmax = m
          yield c
        c += 1
    print(list(islice(g(),16)))

Extensions

a(17) from Michael S. Branicky, Sep 27 2023
a(18)-a(20) from Martin Ehrenstein, Dec 26 2023
a(21)-a(22) from Martin Ehrenstein, Jan 15 2024
a(23) from Martin Ehrenstein, Feb 09 2024

A378628 SHA-256 hash of binary strings ordered by length then lexicographically, interpreting the bits of the resulting hash as a number in binary.

Original entry on oeis.org

102987336249554097029535212322581322789799900648198034993379397001115665086549, 85627803894273957621009139791088467240572419248799306945317937552975942820725, 84071438648566403273885734069370854758478523414599514048347910236850479717025, 91949452561369181223012808967964775320445203057864513807052896586217122700773
Offset: 1

Views

Author

David Rabahy, Dec 02 2024

Keywords

Comments

The n-th binary string is the bits of the binary expansion of n after its most significant 1 bit, so beginning from n=1: [empty], 0, 1, 00, 01, 10, 11, 000, 001, 010, ... .
The SHA-256 hash function takes as input a vector of bits, possibly empty, and the resulting hash is 256 bits so that a(n) ranges 0 to 2^256-1 inclusive.
The length of the input bit vector is part of the hash, so initial 0 bits will, in general, result in a different hash.

Examples

			For n = 1, there are no bits after the most significant 1 bit, so a(1) is the SHA-256 hash of the empty string.
For n = 6 = 110_2, the bits after the most significant 1 are 10, so a(5) is the SHA-256 hash of the bits 10.
		

Crossrefs

Programs

  • Python
    # See links
    
  • Python
    from sha256bit import Sha256bit
    def a(n):
        s = bin(n)[3:]
        t = bytearray(int(s[i*8:i*8+8].ljust(8, "0"), 2) for i in range((len(s)+7)//8)) if n > 1 else ""
        return int(Sha256bit(t, bitlen=len(s)).hexdigest(), 16)
    print([a(n) for n in range(1, 5)]) # Michael S. Branicky, Dec 08 2024
Showing 1-2 of 2 results.