This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
notes:discrete:fall2021:projects:pnf1 [2021/09/09 02:54] – Added trial-by-division method to page smalik3 | notes:discrete:fall2021:projects:pnf1 [2021/09/09 03:59] (current) – [Prime Detection Algorithm] mbrill1 | ||
---|---|---|---|
Line 7: | Line 7: | ||
=====Objective===== | =====Objective===== | ||
+ | |||
Using the TIC-80 fantasy console simulator on your pi, implement a program that visually displays a range of values (lower and upper bounds adjustable by the user) that colorfully displays whether each value is a **prime** or **composite** value. | Using the TIC-80 fantasy console simulator on your pi, implement a program that visually displays a range of values (lower and upper bounds adjustable by the user) that colorfully displays whether each value is a **prime** or **composite** value. | ||
Line 69: | Line 70: | ||
An effective way of going about this project is to allow the prime detection algorithm to " | An effective way of going about this project is to allow the prime detection algorithm to " | ||
+ | |||
====Prime Detection Algorithm==== | ====Prime Detection Algorithm==== | ||
Line 96: | Line 98: | ||
For our upper bound, we want to prioritize testing to what we // | For our upper bound, we want to prioritize testing to what we // | ||
+ | |||
+ | We must consider other options, optimizations, | ||
Now that you understand the general process of this algorithm, and what its lower and upper bounds should be, you can finally get into writing this algorithm. Here are a few concluding questions: | Now that you understand the general process of this algorithm, and what its lower and upper bounds should be, you can finally get into writing this algorithm. Here are a few concluding questions: | ||
Line 104: | Line 108: | ||
==Optional Functionality== | ==Optional Functionality== | ||
+ | |||
This can be relatively simply and familiarly implemented (at a high level) in the way that the **chmod** accepts permission codes. By assigning each optional optimization to a number (in binary terms, starting with 1, 2, 4, 8, 16, ...) and passing the set of selected optimizations as the sum of those selected numbers, the algorithm can handle, in a way of limited individual variables, optional functions. At runtime, these can be checked from greatest to least: if the options argument is a number greater than the number corresponding to the biggest number, perform that operation, and subtract that value from the argument, then move on to the next-biggest, | This can be relatively simply and familiarly implemented (at a high level) in the way that the **chmod** accepts permission codes. By assigning each optional optimization to a number (in binary terms, starting with 1, 2, 4, 8, 16, ...) and passing the set of selected optimizations as the sum of those selected numbers, the algorithm can handle, in a way of limited individual variables, optional functions. At runtime, these can be checked from greatest to least: if the options argument is a number greater than the number corresponding to the biggest number, perform that operation, and subtract that value from the argument, then move on to the next-biggest, | ||
In the case of Break, Odds, and Square Root methodology, | In the case of Break, Odds, and Square Root methodology, | ||
==If Statements== | ==If Statements== | ||
+ | |||
An if statement can be used to accept two conditions instead of just one. In Lua, this is accomplished with `and.` As an example, `if a==2 and b==3 then` only performs an action if a=2 and b=3. This is useful for having multiple menus and deciding which sub-menu to display. It can also be used in conjunction with Optional Functionality. | An if statement can be used to accept two conditions instead of just one. In Lua, this is accomplished with `and.` As an example, `if a==2 and b==3 then` only performs an action if a=2 and b=3. This is useful for having multiple menus and deciding which sub-menu to display. It can also be used in conjunction with Optional Functionality. | ||
+ | |||
+ | |||
+ | ====Break On Composite Algorithm==== | ||
+ | |||
+ | The idea of the "break on composite algorithm", | ||
====Display==== | ====Display==== | ||
=====References===== | =====References===== | ||
+ | |||
https:// | https:// | ||
Line 117: | Line 129: | ||
https:// | https:// | ||
+ | |||
=====Submission===== | =====Submission===== | ||
+ | |||
I'll be looking for the following: | I'll be looking for the following: | ||