mishadoff thoughts

random thoughts about programming, math and life

Fast Factorial

Factorial function is simple enough. But there is still some fun about it. In Stirling’s Approximation article we’ve seen how to calculate good factorial approximation faster than exact value. By the way, there is an algorithm to calculate exact value of factorial faster than “by definition”.

Clojure Euler: Problem 018

By starting at the top of the triangle below and moving to adjacent numbers on the row below, the maximum total from top to bottom is 23.

1
2
3
4
   3
  7 4
 2 4 6
8 5 9 3

That is, 3 + 7 + 4 + 9 = 23.

Find the maximum total from top to bottom of the triangle below:

[Check out big triangle in original link]

NOTE: As there are only 16384 routes, it is possible to solve this problem by trying every route. However, Problem 67, is the same challenge with a triangle containing one-hundred rows; it cannot be solved by brute force, and requires a clever method! ;o)

Permalink: http://projecteuler.net/problem=18

Programming Digest 2

Why math is needed for developers, what is REST, how to become experienced developer…in 10 years, “coding it’s just writing” and some practice: Naive Bayes Classifier, functional programming and Java 8.

Java Magic. Part 4: sun.misc.Unsafe

Java is a safe programming language and prevents programmer from doing a lot of stupid mistakes, most of which based on memory management. But, there is a way to do such mistakes intentionally, using Unsafe class.

This article is a quick overview of sun.misc.Unsafe public API and few interesting cases of its usage.