Project Euler/5

From Esolang
Jump to navigation Jump to search

Back to User:ProjectEuler

Project Euler Problem 5 is related to the concept of Lowest Common Multiple. The task is to work out the lowest common multiple of all integers from 1 through 20.

This article is not detailed enough and needs to be expanded. Please help us by adding some more information.

Implementations

Aheui

Warning: tall stack

This program searches for the smallest multiple of 20, then searches for the smallest multiple of 19 among the multiples of 20, and then searches for the smallest multiple of 18 among the multiples of 20×19, and so on.

발발나싹발밤따뿌망희
뿌석뻐서썬뻐석처속
사싹샥도루발나툐
빠쌱션속쳐볼서

Python

Python has a library with a LCM function, so we don't need to manually define it this time.

# Euler Problem 5
# by Europe2048

import math
for i in range(1, 21):
    for j in range(1, 21):
        print(math.lcm(i, j), end = " ")
    print("\n")

External resources

  • Problem 5 on Project Euler Official Website (not available)
  • Problem 5 on Project Euler Mirror