Archives for math

Entropy of iPhone headphone cables (an excuse to experiment with WP-LaTeX)

Why is it that iPhone earbuds seem to tangle with so many more hopeless tangles than any other cables? Of course, this whole exercise was an excuse to play with LaTeX and the WP-LaTeX plugin. I also managed to find a nice LaTeX cheat sheet in the process.

Google Calculator cheat sheet

I just found an awesome site describing some of the features in Google while looking for info on Google Calculator:  Google Guide My first find was the Quick Reference: Google Calculator (Cheat Sheet). I like this tip from Google Guide solutions to Calculator problems: Compute the probability of your winning the lottery if you buy [...]

Optimized prime number generator

Same specs as previous system, 8 hours to find all primes to ULONG_MAX. #include <stdio.h>#include <malloc.h>#include <limits.h>#include <math.h> struct linked_list{ unsigned long number; struct linked_list *next;}; int main(int argc, char **argv){ unsigned long divisor, max_divisor, prime_test; unsigned long max_prime_to_store; struct linked_list *first=NULL, *current=NULL, *last=NULL; first=(struct linked_list *)malloc(sizeof(struct linked_list)); first->number = 2L; first->next = NULL; last [...]

I miss C programming. Program to find prime numbers

Uses unsigned long long, goes up to ULONG_LONG_MAX. Intel Core Duo 2 processor, running Cygwin on Windows XP, and compiled using gcc 3.4.4. Stops at first million results due to time. Can reasonably get to 10 million, if you’re willing to wait. #include <stdio.h>#include <math.h>#include <limits.h> int main(int argc, char **argv){ unsigned long long divisor, [...]