4 kyu
Twice linear
585 of 24,452g964
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 | 88044 |
Total Skips | 22297 |
Total Code Submissions | 237806 |
Total Times Completed | 24452 |
Ruby Completions | 585 |
Python Completions | 8209 |
JavaScript Completions | 5955 |
CoffeeScript Completions | 23 |
Java Completions | 3062 |
C# Completions | 1419 |
Haskell Completions | 350 |
Clojure Completions | 95 |
C++ Completions | 1949 |
PHP Completions | 428 |
TypeScript Completions | 414 |
Crystal Completions | 14 |
F# Completions | 47 |
C Completions | 829 |
Rust Completions | 595 |
Swift Completions | 182 |
Go Completions | 508 |
R Completions | 97 |
Shell Completions | 21 |
OCaml Completions | 42 |
Objective-C Completions | 17 |
Kotlin Completions | 237 |
Julia Completions | 54 |
Fortran Completions | 16 |
NASM Completions | 13 |
Elixir Completions | 35 |
Scala Completions | 147 |
PowerShell Completions | 28 |
Nim Completions | 11 |
Reason Completions | 4 |
Racket Completions | 25 |
Prolog Completions | 16 |
Haxe Completions | 12 |
Dart Completions | 126 |
CommonLisp Completions | 33 |
Pascal Completions | 12 |
Factor Completions | 9 |
Raku Completions | 11 |
Perl Completions | 19 |
Lua Completions | 58 |
Elm Completions | 4 |
COBOL Completions | 11 |
D Completions | 10 |
Erlang Completions | 6 |
Total Stars | 2909 |
% of votes with a positive feedback rating | 88% of 2852 |
Total "Very Satisfied" Votes | 2308 |
Total "Somewhat Satisfied" Votes | 432 |
Total "Not Satisfied" Votes | 112 |