So I have this code in python, but it wont run as numbers are too large for python to handle, I've found out that there is such thing as Cobra which works faster, almost as C++ and can handle a task like this. I've tried rewriting the code myself, but I keep getting compiling errors, I'm compiling at online compiler tio.run
Here is the original code:
def fib(n):
a = 0
b = 1
for _ in range(n):
a, b = b, a + b
return a
def power(x, e, n):
return pow(x, e) % n
def get_hash_sum():
n = power(power(13371337, 0xdeadbeeffeeddeef, 0xffffffffffffffff), 0xcafecafeabcd, 0xfffffff)
res = 0
while n > 0:
res += fib(n)
n = n // 2 if n % 2 == 0 else (n - 1) // 2
return res & 0xffffffffffffffff
def main():
print(f'Flag is Course{{{get_hash_sum()}}}')
if __name__ == '__main__':
main()
And here is what I've achieved trying to rewrite it based on my research on difference between python and cobra on the internet, which is pretty poor.
class Fibb
def fib(n)
a = 0
b = 1
for _ in range(n)
a, b = b, a + b
return a
class Pow
def power(x, e, n)
return pow(x, e) % n
class Hash
def get_hash_sum()
n = Pow.power(Pow.power(13371337, 0xdeadbeeffeeddeef, 0xffffffffffffffff), 0xcafecafeabcd, 0xfffffff)
res = 0
while n > 0
res += Fibb.fib(n)
n = n // 2 if n % 2 == 0 else (n - 1) // 2
return res & 0xffffffffffffffff
class Program
def main
print(f'Flag is Course{{{Hash.get_hash_sum()}}}')