Project Euler Problem 1

So far, I’ve solved 23 problems on Project Euler, I just want to share my code here.

Disclaimer: if you haven’t solve the problem, do not read any of my project euler related posts.

Problem 1, simple brute force in Perl:

my $sum=0;
for (my $i=1;$i<1000;$i++) {
	$sum+=$i if ($i%3==0 || $i%5==0);
}
print $sum;

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s