6 kyu
Collatz
1,523 of 5,274trent.armstrong
Description:
Preface
A collatz sequence, starting with a positive integern, is found by repeatedly applying the following function to n until n == 1 :
A more detailed description of the collatz conjecture may be found on Wikipedia.
The Problem
Create a function collatz
that returns a collatz sequence string starting with the positive integer argument passed into the function, in the following form:
"X0->X1->...->XN"
Where Xi is each iteration of the sequence and N is the length of the sequence.
Sample Input
Input: 4
Output: "4->2->1"
Input: 3
Output: "3->10->5->16->8->4->2->1"
Don't worry about invalid input. Arguments passed into the function are guaranteed to be valid integers >= 1.
Number Theory
Algorithms
Similar Kata:
Stats:
Created | Nov 15, 2013 |
Published | Nov 16, 2013 |
Warriors Trained | 7039 |
Total Skips | 317 |
Total Code Submissions | 13691 |
Total Times Completed | 5274 |
JavaScript Completions | 1523 |
Haskell Completions | 294 |
Ruby Completions | 319 |
Python Completions | 1845 |
Elixir Completions | 198 |
C# Completions | 388 |
Java Completions | 585 |
C Completions | 175 |
Factor Completions | 11 |
Rust Completions | 107 |
Julia Completions | 21 |
CoffeeScript Completions | 12 |
Crystal Completions | 10 |
Go Completions | 90 |
Scala Completions | 19 |
Total Stars | 103 |
% of votes with a positive feedback rating | 94% of 739 |
Total "Very Satisfied" Votes | 654 |
Total "Somewhat Satisfied" Votes | 80 |
Total "Not Satisfied" Votes | 5 |
Total Rank Assessments | 6 |
Average Assessed Rank | 6 kyu |
Highest Assessed Rank | 5 kyu |
Lowest Assessed Rank | 7 kyu |