Project Euler problem 1 13 November 2015 on project euler, erlang, perl, python Multiples of 3 and 5 If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. Find the sum of all the multiples of 3 or 5 below 1000. Link to original description Source code examples on Github Erlang version 1 2 3 4 5 6 7 8 9 10 11#!/usr/bin/env escript %% -*- erlang -*- %%! -smp enable -sname p1 % vim:syn=erlang -mode(compile). main(_) -> Answer = lists:sum([ X || X <- lists:seq(1,999), X rem 5 =:= 0 orelse X rem 3 =:= 0]), io:format("Answer: ~p ~n", [Answer]). Perl version 1 2 3 4 5 6 7 8 9 10 11 12#!/usr/bin/perl -w use strict; sub main(){ my $answer = 0; for(1..999){$answer += $_ if(!($_ % 3) || !($_ % 5))} print "Answer: $answer \n" } main(); Python version 1 2 3 4 5 6 7 8 9 10#!/usr/bin/python import math def main(): answer = sum(x for x in range(1, 1000) if not(x % 3) or not(x % 5)) print "Answer: %d" % answer main() Please enable JavaScript to view the comments powered by Disqus.