6 kyu
Sequence of squared digits
Description:
Introduction
Consider the first 16 terms of the series below:
11,32,53,94,135,176,217,298,379,460,541,622,703,784,865,1026...
which is generated by this sequence:
11,21,21,41,41,41,41,81,81,81,81,81,81,81,81,161...
.
Each term u
of the sequence is obtained by finding the:
(last power of 2) * 10 + 1
if u
is not a power of 2.
oru * 10 + 1
if u
is a power of 2.
Please note that u
starts at 1 and not 0.
Task
Given variable n
, calculate the n
th term of the series shown above.
Tests
- 10 fixed tests: First 10 terms
- 100 random tests: 1e100 < n < 1e101
Notes:
- Naive solutions won't pass, so don't try to generate the sequence.
- Aim for a sublinear solution (constant time is possible but not required).
Algorithms
Mathematics
Logic
Similar Kata:
Stats:
Created | Oct 13, 2020 |
Published | Oct 13, 2020 |
Warriors Trained | 608 |
Total Skips | 26 |
Total Code Submissions | 487 |
Total Times Completed | 129 |
Python Completions | 129 |
Total Stars | 17 |
% of votes with a positive feedback rating | 87% of 42 |
Total "Very Satisfied" Votes | 35 |
Total "Somewhat Satisfied" Votes | 3 |
Total "Not Satisfied" Votes | 4 |
Total Rank Assessments | 12 |
Average Assessed Rank | 6 kyu |
Highest Assessed Rank | 5 kyu |
Lowest Assessed Rank | 8 kyu |