Tag Archives: prime numbers

Use a bitmap to visualize composite runs in C#

I promise this is my last post on primes for a while. (Sometimes one example leads to another, which leads to another, and so on.) This example draws a bitmap to help visualize composite runs and prime numbers. The basic … Continue reading

Posted in algorithms, graphics, image processing, mathematics | Tagged , , , , , , , , , , , , , | Leave a comment

Find runs of composite numbers (non-primes) in C#

I recently had a birthday and my age is a prime number, so like any normal person I was wondering how long a run of consecutive composite numbers comes after my current age. (Doesn’t everyone wonder such things?) This example … Continue reading

Posted in algorithms, mathematics | Tagged , , , , , , , , , , | Leave a comment

Use a bitmap to visualize odd primes in C#

This example modifies the program in Use a bitmap to visualize primes in C# to let you visualize odd primes. It creates an is_prime array like the previous example does, but it makes the array twice as large as before. … Continue reading

Posted in algorithms, graphics, image processing, mathematics | Tagged , , , , , , , , , , , , , | 1 Comment

Use a bitmap to visualize primes in C#

This example makes a bitmap that helps you visualize primes. The example uses the techniques described in the post Use Euler’s Sieve to find prime numbers in C# to build a table of prime numbers. It then makes a bitmap … Continue reading

Posted in algorithms, graphics, image processing, mathematics | Tagged , , , , , , , , , , , , | 7 Comments

Use Euler’s Sieve to find prime numbers in C#

The Sieve of Eratosthenes is a simple way to make a list of prime numbers. The basic idea is to make an array of numbers. Starting with 2, cross out all multiples of 2 greater than 2. Next cross out … Continue reading

Posted in algorithms, mathematics | Tagged , , , , , , , , , , , , | 6 Comments

Use the Sieve of Eratosthenes to find prime numbers in C#

To use the Sieve of Eratosthenes, you start with a table (array) containing one entry for the numbers in a range between 2 to some maximum value. This table keeps track of numbers that are prime. Initially every number is … Continue reading

Posted in algorithms, mathematics | Tagged , , , , , , , , , | 3 Comments

Find a number’s prime factors in C#

Once upon a time, I read an article where the author said something like this: My professor asked us whether we had prime factored our Social Security numbers yet. Being a normal person, I laughed with everyone else. Being a … Continue reading

Posted in algorithms, mathematics | Tagged , , , , , , , , , , , | 5 Comments