User Tools

Site Tools


notes:comporg:projects:pnc0

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
notes:comporg:projects:pnc0 [2018/01/21 01:50] – [Program Specifications] ahought2notes:comporg:projects:pnc0 [2018/01/22 13:51] (current) – [Program Output Format] bstrong2
Line 105: Line 105:
  
 **Square root trick** - You can use the <math.h> include file with **sqrt()** function or approximate the square root process using logic (this could potentially save runtime because you are not checking as many things as the sqrt function would check through).  The premisis is that you only need to check factors of a number up until the Square root of that number.  For example the square root of 25 is 5.  This tells us that you only need to check factors 2 through 5 to find if this number is a prime or not. **Square root trick** - You can use the <math.h> include file with **sqrt()** function or approximate the square root process using logic (this could potentially save runtime because you are not checking as many things as the sqrt function would check through).  The premisis is that you only need to check factors of a number up until the Square root of that number.  For example the square root of 25 is 5.  This tells us that you only need to check factors 2 through 5 to find if this number is a prime or not.
 +<code>
 +#include <math.h>
 +</code>
 +
 +**sqrt()-less square root approximation (a)-** This is optional, you would do this instead of the sqrt() function. (If you've taken discrete then you know how to do it, if you haven't taken discrete and are looking for moar then this is an option.) The sqrt function in the math library does an exact calculation of a square root. Since we are only dealing with whole numbers for our prime project it is possible to create your own logic to approximate the square root. Since the sqrt function will run for every number that is being checked you are looking at quite a performance increase.
 ---- ----
-**primereg** - baseline program (Brute force, no break)\\ \\ +**primereg.c** - baseline program (Brute force, no break)\\ \\ 
-**primeregs** - baseline, plus square root trick (Use <cmath> or <math.h> header for sqrt())\\ \\ +**primeregs.c** - baseline, plus square root trick (Use <cmath> or <math.h> header for sqrt())\\ \\ 
-**primeregb** - baseline, plus break on composite\\ \\ +**primeregb.c** - baseline, plus break on composite\\ \\ 
-**primeregbs** - baseline, plus square root trick, plus break on composite\\ \\+**primeregbs.c** - baseline, plus square root trick, plus break on composite\\ \\
 **__Choice of A, R, or L__** \\ **__Choice of A, R, or L__** \\
-**primeregAbs** - baseline, array, square root trick, break on composite \\ \\+**primeregAbs.c** - baseline, array, square root trick, break on composite \\ \\
 **Note**: (Store prime divisors into array and check against the array) \\  **Note**: (Store prime divisors into array and check against the array) \\ 
 Array size(amount of elements) == argument 1(number of primes) \\ \\ Array size(amount of elements) == argument 1(number of primes) \\ \\
-**primeregRbs** - Recursive brain melter ? \\ +**primeregRbs.c** - Recursive brain melter ? \\ 
-**primeregLbs** - Linked List - similar to primeregAbs - save primes in a linked list rather than an array.  Also include the break on composite and square root trick.+**primeregLbs.c** - Linked List - similar to primeregAbs - save primes in a linked list rather than an array.  Also include the break on composite and square root trick.
  
  
Line 130: Line 135:
  
 -**Put all c files in gcc directory from pnc0 grabit** \\ -**Put all c files in gcc directory from pnc0 grabit** \\
--Numbers go to stderr, time goes to stdout \\+-Numbers go to stderr, **time goes to stdout** \\
  
 =====Testing===== =====Testing=====
notes/comporg/projects/pnc0.1516499435.txt.gz · Last modified: 2018/01/21 01:50 by ahought2