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

Comments on Find near miss prime multiples.

Post

Find near miss prime multiples.

+2
−0

Given a number n3 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 k1, 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:

100mod2101mod3100mod5103mod7

Since 10mod73, 10 is not a solution so we try the next number.

  • 114mod7 so we try the next number.
  • 122mod5, so we try the next number.
  • 133mod5, so we try the next number.
  • 143mod11, so we try the next number.
  • 154mod11, so we try the next number.
  • 162mod7, so we try the next number.
  • 172mod5, so we try the next number.
  • 183mod5, so we try the next number.
  • 195mod7, so we try the next number.
  • 209mod11, so we try the next number.
211mod2210mod3211mod5210mod7211mod11

21 satisfies the property so its the answer.

Task

Take as input n3 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 attention from curators or moderators?
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)
Can you give a example program? The challenge is hard to understand (at least for me). And how can th...
H_H‭ wrote over 1 year ago

Can you give a example program? The challenge is hard to understand (at least for me). And how can the result be exactly 1,0,1 even when n>3, wouldn't that imply a result with more numbers?

WheatWizard‭ wrote over 1 year ago

The result can be exactly 1,0,1 if no other residue is one of those three residues (and each of those three occurs at least once).

For example look at the example 6. 6 is 0 mod 2, 0 mod 3, 1 mod 5, -1 mod 7. The value 0 occurs twice, this is how you only have 3 values for high n.