Skip to content

Instantly share code, notes, and snippets.

@shihashi
Created September 23, 2022 06:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shihashi/5a8b063b25600bf8f71f426270d7078d to your computer and use it in GitHub Desktop.
Save shihashi/5a8b063b25600bf8f71f426270d7078d to your computer and use it in GitHub Desktop.
Verify Gen's hypothesis on September 23, 2022
#!/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