In my quest to read all the books I have lying on my bookshelf I have finally got round to finishing C# Concisely (ISBN 0-321-15418-5). While this book was fairly old, I found it to be quite useful for a student wanting to learn C# for the first time, and a nice way to review and make I hadn’t missed something when I was learning the language. The book is simple and explains the basic concepts in a clean manner, but is really intended for the beginner programmer – it also had a few chapters dedicated ......

The Problem The following iterative sequence is defined for the set of positive integers: n n/2 (n is even) n 3n + 1 (n is odd) Using the rule above and starting with 13, we generate the following sequence: 13 40 20 10 5 16 8 4 2 1 It can be seen that this sequence (starting at 13 and finishing at 1) contains 10 terms. Although it has not been proved yet (Collatz Problem), it is thought that all starting numbers finish at 1. Which starting number, under one million, produces the longest chain? NOTE: ......

Something that I wasn’t aware was possible in C# was double for loops… they have the following format. for (int x = 0, y = 0; x < 10; x++, y=x*2) { Console.Write("{0} ", y); } Console.ReadLine(); This would give you the following output… 0 2 4 6 8 10 12 14 16 18 In fact you can use as many variables as you want, the following would also be valid… for (int x = 0, y = 0, z = 10; x < 10; x++, y=x*2) { Console.Write("{0} ", z); } Console.ReadLine(); ......

The Problem Work out the first ten digits of the sum of the following one-hundred 50-digit numbers. 371072875339021027987979982... 463769376774900097126481248... 743249861995247410594742333... 919422133635741615725224305... 230675882075393461711719803... 892616706966236338201363784... 281128798128499794080654819... 442742289174325203219235894... ......

This was probably one of the easiest ones to complete – a quick bash got me the following… The Problem n! means n (n 1) ... 3 2 1 For example, 10! = 10 9 ... 3 2 1 = 3628800, and the sum of the digits in the number 10! is 3 + 6 + 2 + 8 + 8 + 0 + 0 = 27. Find the sum of the digits in the number 100! The Solution private static BigInteger Factorial(int num) { if (num > 1) return (BigInteger)num * Factorial(num - 1); else return 1; } private static BigInteger SumDigits(string digits) { BigInteger ......

I have seen the rx demos by Bart De Smet and was blown away by the potential that I think they hold – however I just haven’t had time up till now to have a look at them in any depth. Today I finally set some time aside and got a 10 000 foot view of them. So my plan is for the next few days to develop an application in WPF that makes use of reactive extensions as a dummy project… Today I just wanted to get the basics working, and after going through an very good lab on rx was able to get a very basic ......

It has been a while since I have attempted a project Euler problem, mainly because of university exams taking up the majority of my spare time, but today I managed to spare a few minutes to make an attempt at problem 11. The Problem In the 2020 grid below, four numbers along a diagonal line have been marked in red. 08 02 22 97 38 15 00 40 00 75 04 05 07 78 52 12 50 77 91 08 49 49 99 40 17 81 18 57 60 87 17 40 98 43 69 48 04 56 62 00 81 49 31 73 55 79 14 29 93 71 40 67 53 88 30 03 49 13 36 65 52 70 ......