41
1
Out of all the years I've been making this challenge, 2017 is the first year that's been a prime number. So the question will be about prime numbers and their properties.
Your task is to produce a program or function that will take an arbitrarily large positive integer as input, and output or return whether or not the number is 2,017-friable — that is, whether the largest prime factor in that number is 2,017 or less.
Some example inputs and their outputs:
1 (has no prime factors)
true
2 (= 2)
true
80 (= 2 x 2 x 2 x 2 x 5)
true
2017 (= 2017)
true
2019 (= 3 x 673)
true
2027 (= 2027)
false
11111 (= 41 x 271)
true
45183 (= 3 x 15061)
false
102349 (= 13 x 7873)
false
999999 (= 3 x 3 x 3 x 7 x 11 x 13 x 37)
true
1234567 (= 127 x 9721)
false
4068289 (= 2017 x 2017)
true
Your program does not have to literally output true
and false
— any truthy or falsy values, and in fact any two different outputs that are consistent across true and false cases are fine.
However, you may not use any primes in your source code. Primes come in two types:
Characters, or sequences of characters, that represent prime number literals.
The characters
2
,3
,5
, and7
are illegal in languages where numbers are valid tokens.The number
141
is illegal because it contains41
, even though1
and4
are otherwise valid.The characters
B
andD
(orb
andd
) are illegal in languages where they are typically used as 11 and 13, such as CJam or Befunge.
Characters that have prime-valued Unicode values, or contain prime-valued bytes in their encoding.
The characters
%)+/5;=CGIOSYaegkmq
are illegal in ASCII, as well as the carriage return character.The character
ó
is illegal in UTF-8 because its encoding has0xb3
in it. However, in ISO-8859-1, its encoding is simply0xf3
, which is composite and therefore okay.
The shortest code to do the above in any language wins.
Side note: "friable" is an improvement being adopted over the old-and-undescriptive "smooth" in this context. – Greg Martin – 2017-01-01T00:06:58.907
@GregMartin Done. – Joe Z. – 2017-01-01T00:18:39.247
1Do truthy and falsy values need to be consistent? Or can they vary as long as they are truthy or falsy? – Luis Mendo – 2017-01-01T01:10:50.800
10The lack of
=
rules out most standard languages... – Neil – 2017-01-01T01:12:38.750@LuisMendo They need to be consistent, yes. One output for true, another for false. – Joe Z. – 2017-01-01T01:22:41.570
This may be handy to check if characters are prime when encoded in ASCII. Just paste your code (one line) as input. The result should be all zeros – Luis Mendo – 2017-01-01T02:07:41.573
4-1 for a do X without Y challenge. It's really quite trivial hidden behind a rather unnecessary set of character restrictions – Downgoat – 2017-01-02T02:06:17.743
Why is tab illegal? Its ASCII value is 9. Are you perhaps thinking of vertical tab (11), which no one ever uses? – jwodder – 2017-01-02T02:42:03.233
Yes, I meant vertical tab. Looks like I misunderstood the purpose of that character when I read about it. – Joe Z. – 2017-01-02T03:51:53.757
@Downgoat I'm actually surprised the downvote-to-upvote ratio is so small myself. I thought given all the talk about my first New Year's Puzzle being a broken window that nobody would appreciate a challenge like this one anymore. But thankfully it seems like it's unique enough to be good, since some the answers like Dennis's are actually doing some pretty clever stuff. – Joe Z. – 2017-01-02T03:55:23.910
1I don't like the part about them being arbitrarily large. It would be better if they went up to 2^31-1. – Bijan – 2017-03-16T21:13:38.297
I think the the test case
1234567
is wrong,9721
is bigger than2017
– Embodiment of Ignorance – 2019-04-25T03:41:30.017