mirror of
https://github.com/rzmk/ladderz.git
synced 2025-12-19 06:59:25 +00:00
fix: use end variable instead of n for get_primes_in_range
This commit is contained in:
parent
2ec77987ef
commit
065c233986
2 changed files with 8 additions and 8 deletions
|
|
@ -284,11 +284,11 @@
|
|||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"**Write a program that finds all prime numbers of a positive integer `n` in the range `[start, n]`.**\n",
|
||||
"**Write a program that finds all prime numbers in the range `[start, end]` within the natural numbers.**\n",
|
||||
"\n",
|
||||
"- Assume that `start` and `n` are positive integers greater than or equal to 1.\n",
|
||||
"- Assume that `start` and `end` are positive integers greater than or equal to 1.\n",
|
||||
"\n",
|
||||
"For example for `start = 1` and `n = 20`, the output of `get_primes_in_range(1, 20)` may be:\n",
|
||||
"For example for `start = 1` and `end = 20`, the output of `get_primes_in_range(1, 20)` may be:\n",
|
||||
"\n",
|
||||
"```\n",
|
||||
"{2, 3, 5, 7, 11, 13, 17, 19}\n",
|
||||
|
|
@ -301,9 +301,9 @@
|
|||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"def get_primes_in_range(start: int, n: int) -> set:\n",
|
||||
"def get_primes_in_range(start: int, end: int) -> set:\n",
|
||||
" primes: set = set()\n",
|
||||
" for num in range(start, n + 1):\n",
|
||||
" for num in range(start, end + 1):\n",
|
||||
" if is_prime(num):\n",
|
||||
" primes.add(num)\n",
|
||||
" return primes\n",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue