Created
September 23, 2022 06:34
-
-
Save shihashi/5a8b063b25600bf8f71f426270d7078d to your computer and use it in GitHub Desktop.
Verify Gen's hypothesis on September 23, 2022
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# -*- coding: utf-8 -*- | |
# | |
# verify20220923.py | |
# | |
# Copyright (c) 2022 shihashi | |
# | |
from collections.abc import Sequence | |
N_MAX = 25 | |
def get_sign_list(n: int) -> Sequence[int]: | |
sign_list = [-1] | |
for i in range(1, n): | |
sign_list.append(sign_list[i // 2] * (1 - 2 * (i % 2))) | |
return sign_list | |
def main(): | |
n_max = N_MAX | |
sign_tuple = tuple(get_sign_list(2 ** (n_max + 1))) | |
for n in range(1, n_max + 1): | |
sum = 0 | |
for i in range(1, 2 ** (n+1)): | |
sum += sign_tuple[i] * (i ** n) | |
print(f'{n}: {sum}') | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment