It’s been a long while since I last posted. Anyway, this morning I heard about an interesting site while listening to .NET Rocks podcast. It’s called Project Euler. It’s a series of challenging mathematical/computer programming problems that will require more than just mathematical insights to solve. Other people have used different methods/languages in solving these problems. In my case, I think it’s nice idea to try solving these using Powershell.

To begin with, let’s start with the very first problem in the list.

**Euler Problem 1:**

Add all the natural numbers below one thousand that are multiples of 3 or 5.

**Powershell Solution:**

- 999..1|Where{($_%3 -eq 0) -or ($_%5 -eq 0)}| Measure-Object -sum

PS C:\Users\paul> 999..1|Where{($_%3 -eq 0) -or ($_%5 -eq 0)}| Measure-Object -sum

Count : 466

Average : **Sum : 233168 **Maximum :

Minimum :

Property :

Solution was verified from the site.

Syntax highlighting was generated from:

http://www.thecomplex.plus.com/highlighter.html

## No comments:

Post a Comment