Geeks With Blogs
Mark Pearl Euler
Project Euler Problem 14
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: ......

Posted On Saturday, June 25, 2011 10:21 PM

Euler Problem 13
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... ......

Posted On Friday, June 17, 2011 6:02 PM

Euler Problem 20
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 ......

Posted On Friday, June 17, 2011 5:22 PM

Project Euler Problem 11 Solution
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 ......

Posted On Saturday, June 4, 2011 8:18 PM

F# Euler Problem 16
Well after a hectic week of work and studying I eventually had some me time… today I thought I would attempt Euler Problem 16. The Problem 215 = 32768 and the sum of its digits is 3 + 2 + 7 + 6 + 8 = 26. What is the sum of the digits of the number 21000? The Solution So I thought I would get to concerned about length of code, but rather focus on implementing several practices that I have learnt in the last couple of weeks, namely tail recursive functions and composite functions… I initially broke ......

Posted On Thursday, August 19, 2010 9:42 PM

F# – Euler Problem 10
So today I had the pleasure of attempting Euler Problem 10… the problem goes as follows… The Problem The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17. Find the sum of all the primes below two million. The Solution What I enjoyed about this problem is that if you have done the previous Euler problems, then this problem is really just a focus on pure performance as the other aspects of the problem have in essence been solved before. Not that I have found an optimal solution, in fact I was very ......

Posted On Tuesday, August 10, 2010 5:03 PM

Copyright © MarkPearl | Powered by: GeeksWithBlogs.net