#### ALGORITHM

### Surprising applications of math

The comments in the previous post touched on surprising applications of math, so I thought I’d expand this theme into it’s own post. Below I’ll give a couple general examples of surprising applications and then I’ll give a couple more personal applications I found surprising.Number theory has traditionally been the purest of pure mathematics. People study number theory for the joy of doing so, not to make money. At least that was largely true until the advent of public key...

1,266 0 0 MATH ALGORITHMS NUMBER THEORY DIFFERENTIAL EUQATION

### Translating math into code with examples in Java, Racket, Haskell and Python

Discrete mathematical structures form the foundation of computer science.These structures are so universal that most research papers in the theory of computation, programming languages and formal methods present concepts in terms of discrete mathematics rather than code.The underlying assumption is that the reader will know how to translate these structures into a faithful implementation as a working program.A lack of material explaining this translation frustrates outsiders.What deepens that fr...

2,240 0 0 PROGRAM PYTHON MATH ALGORITHMS FORMULA

### Gcd Algorithm with JavaScript

How to find the greatest common divisor between two integers? We may encounter this problem frequently in interviews or other occasions. An efficient metho to find gcd is the Euclidean algorithm, which uses the division algorithm in combination with the observation that the gcd of two numbers also divides their difference: divide 48 by 18 to get a quotient of 2 and a remainder of 12. Then divide 18 by 12 to get a quotient of 1 and a remainder of 6. Then divide 12 by 6 to get...

7,225 2 0 JAVASCRIPT ALGORITHM GCD IMPLEMENTATION

### Permutation algorithm with JavaScript

In secondary school, we have learned permutation. Basically, for n numbers, the number of permutations for these n numbers can be calculated to n! which is called 'n factorial'. But to display all the permutations on the screen, we need to use a recursive function. The problem is how to write this function. Next I write a program to display the permutations for n numbers with JavaScript. First, we need to understand that from these n numbers, we can first take any one number from it, and t...

28,426 0 1 JAVASCRIPT ALGORITHM PERMUTATION IMPLEME

### How Duff’s Device Works

I like C, but I have to admit that, sometimes, “The Old Man of Programming” can be a bit of a killjoy. This is one of the most exciting eras in computer history, but lately, C’s acting like he doesn’t evenwant to have a good time. While the cool kids like Ruby and Haskell are living it up, C’s over in the corner obsessing over bits and bytes and memory alignment and pointers and the stack and machine architecture and unreachable allocations and multiple indirections…and it’s...

1,633 1 0 DUFF DEVICE ALGORITHM SWITCH CASE