Table of Contents

Corning Community College

CSCS2330 Discrete Structures

PROJECT: Prime Number Computation (PNC0)

OBJECTIVE

Start exploring algorithm/implementation comparison and optimization with respect to various approaches of computing prime numbers.

TASK

Implement program in Vircon32 C, that:

* the upper bound should be fairly easy to change, even if it requires an edit and recompile.

* display that N/upper bound

REFERENCE

The following are reference screenshots of what your implementations should approximate.

PNC0

C implementation

EDIT

You will want to go here to edit and fill in the various sections of the document:

PNCX

algorithm: brute force / trial-by-division

variant: naive
START TIMEKEEPING
NUMBER: FROM 2 THROUGH UPPERBOUND:
    ISPRIME <- YES
    FACTOR: FROM 2 THROUGH NUMBER-1:
        SHOULD FACTOR DIVIDE EVENLY INTO NUMBER:
            ISPRIME <- NO
    PROCEED TO NEXT FACTOR
    SHOULD ISPRIME STILL BE YES:
        INCREMENT OUR PRIME TALLY
PROCEED TO NEXT NUMBER
STOP TIMEKEEPING
variant: break on composite (BOC)
variant: odds-only processing
variant: sqrt point
variant: break+odds
variant: break+sqrt
variant: break+odds+sqrt

timing

One way to calculate your runtime is by using the get_frame_counter() Vircon32 function. You will need to first store the start frames (before you tally the prime numbers) and your end frames (after you tally the prime numbers). Subtracting the start frames from the end frames will give you a value that you can use to find your runtime. The get_frame_counter() function obtains the current value of the frame counter (there are 60 frames per second). If you’d prefer, you could use get_time() or get_cycle_counter(). Just remember the runtime will need to be drawn in seconds with three decimal places for milliseconds. Don't forget that you need to restart at 0 after you reach each upper bound!

titles

Vircon32 uses the standard BIOS font with a width and height that may be 10 by 15 or 20…

Your title is:

[type]  upper tally runtime 
======= ===== ===== =======

This can be done by printing every word separately and calculating the correct positions or making each line one string. This can be done like:

print_at( X, Y, "title sequence that is really long" );
print_at( X, Y-10, "===== ======== ==== == ====== ====" );

info

You will need to print the info. This can be done similarly to:

    print type name at an X and Y;
    Add X to itself + some value;
    itoa Value;
    print Value at an X and Y;
    repeat x amount of times;
    Time = SomeTime - OtherTime
    ftoa Value;
    Some string length, manipulation, and copying may be required for printing decimals;

It is suggested that you make this into a function with parameters that you can pass to it. This may be done for cleanliness and ease of use in the future!

Also, two important functions used in the example are the itoa and ftoa functions which are a part of the string.h library. They allow you to convert numbers to strings which will be important for displaying data that you have recorded.

wedge pnc0 runtimes

VerbalGnat48 pnc0 runtimes

MrVengeance pnc0 runtimes

cburling pnc0 runtimes

bpatricelli pnc0 runtimes

amelvil2 pnc0 runtimes

 

SUBMISSION

To be successful in this project, the following criteria (or their equivalent) must be met:

Submit Tool Usage

Let's say you have completed work on the project, and are ready to submit, you would do the following:

lab46:~/src/SEMESTER/DESIG/PROJECT$ submit DESIG PROJECT file1 file2 file3 ... fileN

You should get some sort of confirmation indicating successful submission if all went according to plan. If not, check for typos and or locational mismatches.

RUBRIC

I'll be evaluating the project based on the following criteria:

156:pnc0:final tally of results (156/156)
*:pnc0:submitted C implementation and build files, builds cleanly [26/26]
*:pnc0:processing and output is correct, and to specifications [26/26]
*:pnc0:no optimizations or improvements on the process [26/26]
*:pnc0:graph produced from timing data produced [26/26]
*:pnc0:graph posted to discord and documentation page [26/26]
*:pnc0:timing data is the taken out to 3 decimal places [26/26]

Pertaining to the collaborative authoring of project documentation

Additionally