Daily Challenge (98 Part Series)
Hey, everyone. If yesterday was our rest day, today is the warm-up.
We have another great challenge from user g964 on CodeWars:
Consider a sequence
u, where u is defined as follows:
- The number
u(0) = 1is the first one in
- For each
y = 2 * x + 1and
z = 3 * x + 1must also be in
- There are no other numbers in
u = [1, 3, 4, 7, 9, 10, 13, 15, 19, 21, 22, 27, ...]
1 gives 3 and 4. 3 gives 7 and 10 while 4 gives 9 and 13. This pattern continues as far you as allow it to.
Your task is to create a function
dbl_linearwith a parameter of
nthat returns the element
u(n)in an ordered sequence (excluding duplicates).
Good luck! Let us know if you like these mathematical challenges and we'll stick with the trend.
Want to propose a challenge for a future post? Email email@example.com with your suggestions!