diff --git a/gdb/README.md b/gdb/README.md
index a9b6a61dfcf5f66513e1f34b134bbbbf0b4b9515..bc275bb7e0faae2c2f784e9b628db043551a7126 100644
--- a/gdb/README.md
+++ b/gdb/README.md
@@ -21,6 +21,9 @@ build it from [source](https://www.gnu.org/software/gdb/current/).
 
 ## 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
 
 I'll refrain from
diff --git a/gdb/main.cpp b/gdb/main.cpp
index fb3a887137c2b7e5326f2e8b3ab7aec57b6a87d0..33fd700b8192e287d06d5cde5c488157a0ff2d01 100644
--- a/gdb/main.cpp
+++ b/gdb/main.cpp
@@ -1,8 +1,9 @@
 #include <iostream>
+#include <cmath>
 
 // This is a simple function that checks if numbers are prime. Or does it? There may be a bug...
 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) {
             return false;
         }