# credmp/Blog

1 parent d8b27b8 commit 49843a5351551e7c05ed6c752d3b8be6a94d0288 committed Mar 6, 2013
1 _includes/custom-js.js
 @@ -1,6 +1,7 @@ +
1 _includes/toc
 @@ -0,0 +1 @@ +
3 _includes/toc_call
 @@ -0,0 +1,3 @@ +
27 _posts/2013-02-23-Project-Euler-Problem-1.md
 @@ -0,0 +1,27 @@ +--- +tags: [Erlang, Project Euler] +title: "Project Euler Problem 1" +image: /assets/post_images/project-euler.png +image_credit: Project Euler +layout: post +--- + +Below my solution to the 1st problem of [Project Euler](http://projecteuler.net/problem=1). + +Problem: + +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. + +Solution: + +{% highlight erlang %} +-module(problem1). +-export([main/1]). + +main(Number) -> + lists:sum(lists:filter(fun(X) -> (X rem 3 == 0) or (X rem 5 == 0) end, + lists:seq(1,Number))). +{% endhighlight %}
40 assets/css/toc.css
 @@ -0,0 +1,40 @@ +#toc { + top: 0px; + left: 0px; + height: 100%; + position: fixed; + background: #333; + box-shadow: inset -5px 0 5px 0px #000; + width: 150px; + padding-top: 20px; + color: #fff; +} + +#toc ul { + margin: 0; + padding: 0; + list-style: none; +} + +#toc li { + padding: 5px 10px; +} + +#toc a { + color: #fff; + text-decoration: none; + display: block; +} + +#toc .toc-h2 { + padding-left: 10px; +} + +#toc .toc-h3 { + padding-left: 20px; +} + +#toc .toc-active { + background: #336699; + box-shadow: inset -5px 0px 10px -5px #000; +}
8 assets/js/jquery.toc.min.js
 @@ -0,0 +1,8 @@ +/*! + * jquery.toc.js - A jQuery plugin that will automatically generate a table of contents. + * v0.1.1 + * https://github.com/jgallen23/toc + * copyright JGA 2012 + * MIT License + */ +!function(e){e.fn.toc=function(t){var n=this,r=e.extend({},jQuery.fn.toc.defaults,t),i=e(r.container),s=e(r.selectors,i),o=[],u=r.prefix+"-active",a=function(t){for(var n=0,r=arguments.length;n0)return s;s.scrollTop(1);var o=s.scrollTop()>0;s.scrollTop(0);if(o)return s}return[]},f=a(r.container,"body","html"),l=function(t){if(r.smoothScrolling){t.preventDefault();var i=e(t.target).attr("href"),s=e(i);f.animate({scrollTop:s.offset().top},400,"swing",function(){location.hash=i})}e("li",n).removeClass(u),e(t.target).parent().addClass(u)},c,h=function(t){c&&clearTimeout(c),c=setTimeout(function(){var t=e(window).scrollTop(),i;for(var s=0,a=o.length;s=t){e("li",n).removeClass(u),i=e("li:eq("+(s-1)+")",n).addClass(u),r.onHighlight(i);break}},50)};return r.highlightOnScroll&&(e(window).bind("scroll",h),h()),this.each(function(){var t=e(this),n=e("
BIN assets/post_images/java_from_nothing/2.persistence.png
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN assets/post_images/project-euler.png