Determine the sequence of 1 2 2 3 3 3 4 4 4 4 5 5 5 5 5 on Python 3
📁 Advanced Python Topics, example, work
I try to solve the problem:
Write a program that displays part of the sequence 1 2 2 3 3 3 4 4 4 4 5 5 5 5 5 ... (the number is repeated as many times as its value). The input to the program is a positive integer N — the number of elements of the sequence that the program should output. The output is expected to be a sequence of numbers written separated by spaces on one line.
For example, if n = 7, then the program should output 1 2 2 3 3 3 4.
Sample input: 7
Sample output: 1 2 2 3 3 3 4
No answers yet.
Log in to leave an answer
Blogs
Salaries of JavaScript Developers in Russia: Market Overview for Advanced Professionals
Caching in Swift: Redis, Memcached, and Built-in Solutions from A to Z
Monorepo with Swift: Code Organization for Beginners
OAuth 2.0 and JWT Authorization in Java: Step-by-Step Guide