27
2
Given a nonnegative integer, return whether it is a three digit number ending in one, in any consistent integer base. In other words, the number needs to be represented in base-N, N being an integer greater than zero.
Rules
- This is code-golf, so shortest answer wins.
- Since unary behaves weirdly, the behavior with input 310 is undefined.
- Standard loopholes are prohibited.
Examples
True:
5
73
101
1073
17
22
36
55
99
False:
8
18
23
27
98
90
88
72
68
A handful of large numbers:
46656 true
46657 true
46658 true
46659 true
46660 true
46661 false
46662 false
46663 true
46664 false
46665 true
46666 true
46667 false
46668 false
46669 false
46670 true
46671 true
1Since unary behaves weirdly no, it doesn't behave weirdly, the unary representation of a non-negative integer
n
is justn
1
s, e.g.0 = ()₁
,3 = (111)₁
,10 = (1111111111)₁
, etc. – Erik the Outgolfer – 2017-12-16T09:28:48.250@EriktheOutgolfer every position is worth the same in unary, which is a bit weird for a positional notation. But really, I'm just unsure whether including or excluding unary would waste more bytes for the one special case. – HAEM – 2017-12-16T09:43:31.497
Actually the only thing special about it is that it doesn't have the 0 digit, otherwise it works as any other base. However, your challenge is your decision. – Erik the Outgolfer – 2017-12-16T09:48:32.753
6@EriktheOutgolfer It does behave quite differently; you can't divide by 1 to n-itshift, for example. – wizzwizz4 – 2017-12-16T12:27:56.133
3What does consistent integer base mean? (Also, instead of excluding unary in the rules you could just specify N ≥ 2.) – Lynn – 2017-12-16T14:25:20.670
1@Lynn A positional notation with a single radix, e.g. base ten, as opposed to a position-dependent radix like you see with imperial units or time. – HAEM – 2017-12-16T20:38:35.597
1@Lynn as an addendum, I was also trying to exclude rational, negative, complex etc. bases. As for your second point, the rule about unary is intended to neither include nor exclude unary. Unless my grasp of language lawyering is even feebler than I thought, "undefined behavior" means "whatever the implementing party wants", which is what I was going for. – HAEM – 2017-12-16T20:57:35.480
Sorry but I don't quite follow the discussion about unary. If unary is allowed, then you can hardcode "true" as output because any integer will end in 1 in unary representation. – CompuChip – 2017-12-18T09:46:08.463
@CompuChip this is why the "three digit" requirement is also there, which makes 3 the only unary that returns true. – HAEM – 2017-12-18T09:50:40.517
Ah, that's where I misread... thought the input was a three-digit number (in decimal) and the question was whether it ends in one in any base. Makes sense then. – CompuChip – 2017-12-18T14:50:46.897