John Lekberg


JUNTO Practice - "Project Euler Problem 48"

Discussed on 2018-12-19.

Project Euler Problem 48


Solution - John

#!/usr/bin/env python3

"""pe48.py: Solution to project Euler Problem 48."""

__author__ = "John Lekberg"


def last_n_digits(x: int, n: int):
    """The last 'n' digits of 'x'."""
    assert x >= 0
    assert n >= 1
    return x % 10 ** n


result = sum(i ** i for i in range(1, 1001))

print(last_n_digits(result, n=10))

Solution - Oscar

import itertools as it
import cProfile as cp


def EU48():
    print(str(sum(i ** i for i in range(1, 1001)))[-10:])


cp.run("EU48")