2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder.

What is the smallest number that is evenly divisible by all of the numbers from 1 to 20?

# Category Archives: Software Development

This category contains all my posts about software development. Tutorials, solutions to problems I’ve met, interesting things I’ve stumbled over, code samples, stuff I don’t want to forget, et cetera.

# Project Euler: Problem 4

The fourth problem was a bit tricky, but at the same time a bit funny.

A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91*99.

Find the largest palindrome made from the product of two 3-digit numbers.

# Project Euler: Problem 3

The third Euler problem has to do with prime factorization:

The prime factors of 13195 are 5, 7, 13 and 29.

What is the largest prime factor of the number 600851475143?

# Project Euler: Problem 2

Alright, next Project Euler problem:

Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be:

1, 2, 3, 5, 8, 13, 21, 34, 55, 89, …

Find the sum of all the even-valued terms in the sequence which do not exceed four million.

# Project Euler: Problem 1

Recently I decided that my brain needed some exercise. So I figured I would try to solve a couple of Project Euler problems once in a while. And while I was at it, try to to do a bit of TTD, or at least write test cases for things. What is Project Euler? Well, here is some of what they say about themselves, whoever they are:

Project Euler is a series of challenging mathematical/computer programming problems that will require more than just mathematical insights to solve. Although mathematics will help you arrive at elegant and efficient methods, the use of a computer and programming skills will be required to solve most problems.

The motivation for starting Project Euler, and its continuation, is to provide a platform for the inquiring mind to delve into unfamiliar areas and learn new concepts in a fun and recreational context.

I’m not particularly good at these things, but it is quite fun when you get it right. I also get to practice my Google-Fu a bit when I need to freshen up things I learned during math at school, but have forgotten. Or if I find that my solution to a problem is totally awful and takes ages to solve…

Anyways, I can recommend the problems so far. They have (so far) been mind bending enough to be challenging, but not so insanely difficult that they are impossible.

The first problem goes like this:

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.

And to give you a chance to solve it without seeing my solution, I will put my solution on the next page ðŸ˜‰

# New blog!

Alright, we are doing this again. After having watched a very inspiring session with Scott Hanselman called *Making Your Blog Suck Less: Social Networking and Your Personal Brand Online* at the Norwegian Developer Conference 2009, I figured I should have a go at this thing again. I have had various websites before and a couple of blogs, however they all suffered from me wanting to program more than I wanted to write. That means I usually ended up programming my own stuff, having loads of fun designing, putting things together, forcing some text about myself and what I do out there, and then… well, then they pretty much died.

So, now I am going for WordPress and is hoping that I will manage to stick with it for a while. And hopefully get some stuff out here too. Will try out Scott’s advice on using drafts in Live Writer, etc.

Aaaaanyways, have a look around, drop me an email if you want, comment on stuff, subscribe to my feed, et cetera. Or just ignore me. That is fine by me too ðŸ˜›

**By the way** if you are interested in seeing that very good session, you can find them here. I recommend downloading it using the BitTorrent file you find there. If you think it is a bit much, just use a decent BitTorrent client like ÂµTorrent and you can select just that file. However I really do recommend that you download the whole thing cause it is a lot of really great stuff there. For example some very good introduction sections to Test-Driven Development with Roy Osherove.

# C#: Handy BCrypt class for hashing passwords

I was working on an application where I needed to store user names and passwords in a database, as we often do. As we all (should) know we never (ever, ever) store passwords in plain text. If we do, we are setting ourselves up for big trouble if the database contents leaks out or someone hacks their way into it. So what should you do?

You should salt the passwords and you should hash them, and hash them good.

Using raw hash functions to authenticate passwords is as naive as using unsalted hash functions. Donâ€™t. – Thomas Ptacek

So, I was looking for a good implementation of a good hashing algorithm and found one written by Derek Slager called BCrypt.net. I really like it. It has a very clean interface and is super easy to use. So to make sure I don’t lose it (if he would remove it or I would lose the link or something), I post it here. And if it helps someone else to discover it and to ease their day a little, that would be awesome too ðŸ™‚

You use it like this:

// amount of resources required to check the password. The work factor

// increases exponentially, so each increment is twice as much work. If

// omitted, a default of 10 is used.

string hashed = BCrypt.HashPassword(password, BCrypt.GenerateSalt(12));

// Check the password.

bool matches = BCrypt.CheckPassword(candidate, hashed);

You find the class here.