HTB Challenge: Primed for Action
Primed for Action
Difficulty: Very easy
URL: https://app.hackthebox.com/challenges/867
Challenge Description
Intelligence units have intercepted a list of numbers. They seem to be used in a peculiar way: the adversary seems to be sending a list of numbers, most of which are garbage, but two of which are prime. These 2 prime numbers appear to form a key, which is obtained by multiplying the two. Your answer is the product of the two prime numbers. Find the key and help us solve the case.
The Challenge
Write a (Python, C, C++ or Rust) script that:
- Takes a single line of space-separated numbers as input.
- Filters out the prime numbers.
- Multiplies them all together.
- Prints only the resulting product — with no additional text, formatting, or debug output.

Solution Design
We approached this with a clean and structured layout.
Input Parsing
The input comes from stdin, typically using input() in Python. We expect a line like:
2 6 7 18 6
Prime Detection
We use a simple but efficient primality test.
Reject numbers less than 2
if n < 2:
return False
Not entering the modern mathematical debate on whether 1 is prime or not –in the context of this script, where we’re multiplying prime numbers, including 1 would have no effect on the final product (1 time x = x).
Check divisibility by 2
if n % 2 == 0:
return False
Check odd divisors up to the square root of the number
for i in range(3, int(n ** 0.5) + 1, 2):
if n % i == 0:
return False
This line defines the range of numbers used to check whether n is divisible by any odd number greater than 2 — which is part of a primality test.
Why start at 3?
We’ve already handled even numbers (specifically 2) earlier in the code. So we skip 2 and start checking from 3.
Why stop at int(n ** 0.5) + 1?
A number cannot be divisible by anything larger than its square root unless it’s also divisible by something smaller. Therefore, it’s enough to check up to and including the square root of n.
Since range() excludes the upper bound, we add +1 to ensure the square root itself is tested.
Why step by 2?
After 2, all even numbers can be skipped — they’re not prime, and they can’t be divisors of an odd number. This optimization cuts the number of checks in half.
Product Calculation
We multiply all primes using a basic loop and an accumulator.
Solution in Python
# Take input: a line of space-separated integers
input_line = input()
# Check whether a number is prime
def is_prime(n):
if n < 2:
return False
if n == 2:
return True
if n % 2 == 0:
return False
for i in range(3, int(n ** 0.5) + 1, 2):
if n % i == 0:
return False
return True
# Convert input to a list of integers
numbers = map(int, input_line.strip().split())
# Multiply all prime numbers found in the input
product = 1
for number in numbers:
if is_prime(number):
product *= number
# Output the result
print(product)
Filed under: challenges,HTB - @ 08/04/2025 22:54