Return to JUNTO

JUNTO Practice: Project Euler Problem 48

Discussed on December 19, 2018.

Project Euler Problem 48


Click to see:

Oscar Martinez

import itertools as it
import cProfile as cp

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

John Lekberg

#!/usr/bin/env python3

""" 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))