Programming

Best Website For Competitive Programmers 2022

Website for Competitive Programmers

There are a lot of websites out there for competitive programmers. But, which one is the best one? Today, I’m going to introduce you to one of the best websites for competitive programming.

You will find a lot of problems on that website. The website name is CSES. And the domain address is cses.fi.

You can solve problems in 10 different programming languages on that website. The language is Assembly, C++, Python, Java, JavaScript, Haskell, Pascal, Ruby, Rust, and Scale. There are 2 different versions of Python out there, the versions are Python2 and Python3.

competitive programmers

Website Image

Read More: Top 5 Programming Languages in Bangladesh 2022

The first problem is the Weird Algorithm. I’m giving this problem in there.

Weird Algorithm

Consider an algorithm that takes as input a positive integer n. If n is even, the algorithm divides it by two, and if n is odd, the algorithm multiplies it by three and adds one. The algorithm repeats this until n is one. For example, the sequence for n=3 is as follows:

3→10→5→16→8→4→2→1

Your task is to simulate the execution of the algorithm for a given value of n.

Input

The only input line contains an integer n.

Output

Print a line that contains all values of n during the algorithm.

Constraints

1≤n≤106

Example

Input:

3

Output:

3 10 5 16 8 4 2 1

Solve this problem and submit it here.

Just go to cses.fi, create an account, and start solving problems. It’s really fun and important for us, to make a better knowledge of programming.

What is your reaction?

0
Excited
0
Happy
0
In Love
0
Not Sure
0
Silly

Comments

  1. shofikul islam parvez says:

    you are the best content writer and I pray that you will be successful oneday in sha Allah and i will try to my best to support you.

Leave a reply

Your email address will not be published. Required fields are marked *