27
3
Your task is pretty simple, calculate the n-th element of A190810.
Elements of A190810 are calculated according to these rules:
- The first element is 1
- The sequence is increasing
- If
x
occurs in the sequence, then2x+1
and3x-1
also do
You can use 1-based or 0-based indexing, but if you use 0-based indexing, please say it in the answer.
Test cases
a(1) = 1
a(2) = 2
a(3) = 3
a(4) = 5
a(5) = 7
a(10) = 17
a(20) = 50
a(30) = 95
a(55) = 255
Since this is code-golf, the shortest answer in bytes wins!
2You should add larger test cases. – mbomb007 – 2016-07-14T14:14:56.810
Can we use zero-based indexing? – PurkkaKoodari – 2016-07-14T14:26:20.793
@Pietu1998 Yeah, i'll clarify that – TuxCrafting – 2016-07-14T14:27:21.463
7Can you explain this a little more clearly? I'm a native English speaker and I have no idea what "... and if x is in a then 2x+1 and 3x-1 are in a." is supposed to mean. – cat – 2016-07-14T16:13:52.333
1@cat
x ϵ A → (2*x) + 1 ϵ A
andx ϵ A → (3*x)-1 ϵ A
, whereϵ
means "is a member of" and→
can be understood as "implies". – Steven H. – 2016-07-14T16:35:32.780A000027 also satisfies all three rules unless you also specify that 1 is the only element not generated by rule 3. – f'' – 2016-07-15T07:01:35.830
3Implied condition: The sequence does not contain numbers not required by the other rules. (Otherwise $a(i)=i$ would be a valid sequence) – Stig Hemmer – 2016-07-15T07:05:10.193
1And you get free Mathematica and Haskell answers to start from :) – OrangeDog – 2016-07-15T12:44:16.257