having fun with code

Tag Archives: math

Russian multiplication in Javascript

Answering this post from The Daily WTF about Russian multiplication, here is my code: function russian(a,b) {   return (a>1)? b*(a&1) + russian(a>>1, b<<1) : b; } russian(18,23); Nice one liner :)

Splitting a vector into two vectors 90 degrees apart

I wanted to add something special to the Particle-Balls demo I made. At first, the idea seemed pretty simple: When clicking on a moving ball, split it in two with a 90° angle between them (π/2 in radians). To keep it simple, both balls will have the same size as the original and the same [...]

Fibonacci vs. 2n

Which sequence of numbers grows faster, Fibonacci or 2n? It seems like 2n grows faster. It only takes 1025 steps to overflow a Javascript numeric variable, while Fibonacci needs 1477 steps. Check it out: http://dev.enekoalonso.com/research/threads-fibonacci-vs-2N.php

About the blog

This is a blog about development, focused mainly on Javascript but also other languages like python, shell scripts and more.

About the author

Eneko Alonso is a software engineer and UI developer with more than eight years of experience in software and web development. He lives in San Luis Obispo, California and works at LEVEL Studios.

Contact Info

Contact Info