Skip to content
Snippets Groups Projects
Commit a341b7c3 authored by Erik Strand's avatar Erik Strand
Browse files

Break the example code

parent 12b118fa
No related branches found
No related tags found
No related merge requests found
...@@ -21,6 +21,9 @@ build it from [source](https://www.gnu.org/software/gdb/current/). ...@@ -21,6 +21,9 @@ build it from [source](https://www.gnu.org/software/gdb/current/).
## Debugging on Your Computer ## Debugging on Your Computer
Let's try running the example program in this directory. It should tell us which numbers are prime.
But there seems to be a problem.
## Debugging on Your Microcontroller ## Debugging on Your Microcontroller
I'll refrain from I'll refrain from
#include <iostream> #include <iostream>
#include <cmath>
// This is a simple function that checks if numbers are prime. Or does it? There may be a bug... // This is a simple function that checks if numbers are prime. Or does it? There may be a bug...
bool is_prime(int x) { bool is_prime(int x) {
for (int i = 2; i < x / 2; ++i) { for (int i = 2; i < std::sqrt(x); ++i) {
if (x % i == 0) { if (x % i == 0) {
return false; return false;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment