Prime Factorization and Debugging Macros
showprimes.cpp         primefactory.hpp         bitmap.hpp          ydebug.hpp
 
This program was written in response to a problem posted on projecteuler.net. Please note that is is NOT a solution to the problem, projecteuler asks that the solutions not be posted.
 
I wrote this program to demonstrate three things
  1. Determining prime numbers using the Sieve of Eratosthenes
  2. Using that sieve to find the prime factors of a number
  3. Showcase some C++ debugging macros I wrote.
 
I was intentionally rather sparse in writing comments for the program, preferring to think that its functioning is self-evident.
If you don't think so, please, please, please write me with constructive suggestions at
.maintainer@intricate‑simplicity.com
 
Usage:
 
showprimes number [number ...]
displays, in debugging messages, the prime factorization of number(s), both factors and exponent (number of times that factor occurs).
 
Debugging macros
 
I've included my C++ debugging macro file. It's purpose is to make it simple to print values of variables in a uniform format.
 
The basic macro, DB prints the variable and its value. For example
the statement DB(var) would print var=value when it was executed.
 
There are variations of that macro to print 2, 3, 4, and more variable values
on the same line (DB2, DB3, DB4, etc.).
 
Output Notes:
 
Because this program demonstrates the debugging macros the output is not very pretty. LOUD and be #defined to display the extra information printed that I used for debugging during development.
 
Sample Output:
 
david@godel: showprimes 6883727711
i=1 composite=6883727711
composite=6883727711 maxPrime=82969
i_factor->value=7 i_factor->exponent=3
i_factor->value=359 i_factor->exponent=1
i_factor->value=55903 i_factor->exponent=1
6883727711 = 7**3 * 359**1 * 55903**1
 
 
C++ Note:
 
I compiled and ran this program on my personal system. Because it is my personal system I placed the header file ydebug.hpp in the ⁄usr⁄include directory so that I could include it in programs with the statement
#include <ydebug.h> and it would not matter which directory housed the source program
If you want to compile it without modifying usr⁄include change the line above to
#include "ydebug.h" and put the file ydebug.h in the same directory as the source file.
Previous  |  Next ]     [ Up  |  First  |  Last ]     (Article 18 of 485)
 
Comments, flames, broken links?
Please send email to maintainer@intricate-simplicity.com