Generating many prime numbers

Leonhard Euler

Today, a fellow student claimed that it would take much time to check the first 1,000,000 numbers for primes. I claimed that it would be a matter of seconds to do so for the first 1,000,000,000 numbers. So, lets prove my claim. Trivial approach Execute it for 100,000,000: So 41 seconds for all primes not [...]

Solving equations of upper triangular matrices

Upper triangular matrices

Suppose you have an equation like with and . and are given and you want to solve for . Example With , the problem could look like this: This is only a shorthand for: First step: Solve for First you see that . So you divide by the current row. Don’t divide through 0. When [...]

Solving equations of lower unitriangular matrices

Unipotent lower triangular matrix

Suppose you have an equation like with and . and are given and you want to solve for . Example With , the problem could look like this: This is only a shorthand for: This is easy to solve, isn’t it? First step: Solve for First you see that . Now you replace every occurence [...]

k-nearest-neighbor clustering – an interactive example

k-means interesting setting - thumbnail

When the circle has exactly the same number of blue / green dots in it, it will be green. When you move the mouse over the box, everything will be calculated and drawn again. This leads to flickering with k-means, as k-means includes a random choice of cluster centers. Changelog Version Change 2.1 users can [...]

The Collatz sequence

Collatz sequence - Thumbnail

The goal of this post is to show you some tools that allow you to visualize data. And I also want to analyze some basic characteristics of the Collatz sequence. The Collatz sequences of a number is defined like this: So the sequence is defined as: You can define a directed graph like this: I [...]

Maps in C++

C++ thumb CPP

Maps are one of the most useful datastructures in C++ and there is no excuse for not knowing it. Here is a basic example that shows how you can use it: See also C++ Reference: general information and example Map is ordered collection (source)

Google Code Jam – Round 1C 2013

Google Code Jam Logo Thumbnail

Problem A (Consonants): Small Set: 4305/4834 users (89%) Large Set: 1551/3778 users (41%) Problem B (Pogo): Small Set: 2537/3129 users (81%) Large Set: 121/638 users (19%) Problem C (The Great Wall): Small Set: 934/1260 users (74%) Large Set: 74/330 users (22%) More information is on go-hero.net. Consonants A solution from nip: Pogo This is a [...]