4 kyu
Twice linear
584 of 24,305g964
Description:
Consider a sequence u
where u is defined as follows:
- The number
u(0) = 1
is the first one inu
. - For each
x
inu
, theny = 2 * x + 1
andz = 3 * x + 1
must be inu
too. - There are no other numbers in
u
.
Ex:
u = [1, 3, 4, 7, 9, 10, 13, 15, 19, 21, 22, 27, ...]
1 gives 3 and 4, then 3 gives 7 and 10, 4 gives 9 and 13, then 7 gives 15 and 22 and so on...
Task:
Given parameter n
the function dbl_linear
(or dblLinear...) returns the element u(n)
of
the ordered (with <) sequence u
(so, there are no duplicates).
Example:
dbl_linear(10) should return 22
Note:
Focus attention on efficiency
Mathematics
Algorithms
Similar Kata:
Stats:
Created | Dec 17, 2015 |
Published | Dec 17, 2015 |
Warriors Trained | 87785 |
Total Skips | 22260 |
Total Code Submissions | 237301 |
Total Times Completed | 24305 |
Ruby Completions | 584 |
Python Completions | 8146 |
JavaScript Completions | 5932 |
CoffeeScript Completions | 23 |
Java Completions | 3051 |
C# Completions | 1411 |
Haskell Completions | 348 |
Clojure Completions | 95 |
C++ Completions | 1931 |
PHP Completions | 428 |
TypeScript Completions | 411 |
Crystal Completions | 14 |
F# Completions | 45 |
C Completions | 823 |
Rust Completions | 592 |
Swift Completions | 179 |
Go Completions | 504 |
R Completions | 95 |
Shell Completions | 20 |
OCaml Completions | 42 |
Objective-C Completions | 17 |
Kotlin Completions | 235 |
Julia Completions | 53 |
Fortran Completions | 15 |
NASM Completions | 13 |
Elixir Completions | 34 |
Scala Completions | 147 |
PowerShell Completions | 25 |
Nim Completions | 11 |
Reason Completions | 4 |
Racket Completions | 25 |
Prolog Completions | 16 |
Haxe Completions | 11 |
Dart Completions | 117 |
CommonLisp Completions | 33 |
Pascal Completions | 12 |
Factor Completions | 9 |
Raku Completions | 11 |
Perl Completions | 17 |
Lua Completions | 56 |
Elm Completions | 3 |
COBOL Completions | 10 |
D Completions | 10 |
Erlang Completions | 5 |
Total Stars | 2902 |
% of votes with a positive feedback rating | 89% of 2841 |
Total "Very Satisfied" Votes | 2299 |
Total "Somewhat Satisfied" Votes | 432 |
Total "Not Satisfied" Votes | 110 |