Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Challenges

Find near miss prime multiples.

+2
−0

Given a number $n \geq 3$ as input output the smallest number $k$ such that the modular residues of $k$ by the first $n$ primes is exactly $\{-1,0,1\}$.

That is there is a prime in the first $n$ primes that divides $k$, one that divides $k+1$ and one that divides $k-1$, and every prime in the first $n$ primes divides one of those three values.

For example if $n=5$, the first $5$ primes are $2, 3, 5, 7, 11$ the value must be at least $10$ since with anything smaller $11$ is an issue. So we start with $10$:

$$ 10 \equiv 0 \mod 2 $$$$ 10 \equiv 1 \mod 3 $$$$ 10 \equiv 0 \mod 5 $$$$ 10 \equiv 3 \mod 7 $$

Since $10 \mod 7 \equiv 3$, $10$ is not a solution so we try the next number.

  • $11 \equiv 4\mod 7$ so we try the next number.
  • $12 \equiv 2\mod 5$, so we try the next number.
  • $13 \equiv 3\mod 5$, so we try the next number.
  • $14 \equiv 3\mod 11$, so we try the next number.
  • $15 \equiv 4\mod 11$, so we try the next number.
  • $16 \equiv 2\mod 7$, so we try the next number.
  • $17 \equiv 2\mod 5$, so we try the next number.
  • $18 \equiv 3\mod 5$, so we try the next number.
  • $19 \equiv 5\mod 7$, so we try the next number.
  • $20 \equiv 9\mod 11$, so we try the next number.
$$ 21 \equiv 1 \mod 2 $$$$ 21 \equiv 0 \mod 3 $$$$ 21 \equiv 1 \mod 5 $$$$ 21 \equiv 0 \mod 7 $$$$ 21 \equiv -1 \mod 11 $$

21 satisfies the property so its the answer.

Task

Take as input $n \geq 3$ and give as output the smallest number satisfying.

This is code-golf. The goal is to minimize the size of your source code as measured in bytes

Test cases

3 -> 4
4 -> 6
5 -> 21
6 -> 155
7 -> 441
History
Why does this post require moderator attention?
You might want to add some details to your flag.
Why should this post be closed?

2 comment threads

Can you give a example program? The challenge is hard to understand (at least for me). And how can th... (2 comments)
Verifying my interpretation (3 comments)

0 answers

Sign up to answer this question »