Question: algorithms please use c language Problem #2. Programming 3N 1 Daecheon Kim is very good in mathematics and he love playing with the natural numbers.
Problem #2. Programming 3N 1 Daecheon Kim is very good in mathematics and he love playing with the natural numbers. He plays with a positive number n and repeatedly apply simple rules as follows If n If n is even, divide n by2 If n is odd, multiply n by 3 and add 1 1, stop - He realizes that an arbitrary positive natural number n can reach to 1 after applying above rules k steps For example, k0 if n1 and k 3 if n 8 For a given number of steps k, there are one or more natural number can reach to 1 Daecheon Kim wants to know which are the smallest and largest numbers that reach to 1 after k steps Task Write a program to help him find the smallest and largest number that reach to 1 after k steps Input and Output Input is read from the text file 3n1.inp consisting of only one number k Output is written to the text file 3n1.out consisting of 2 integer numbers which are the smallest and the largest numbers that reach to 1 after k steps (separated by a space) Example: 3n1.in 3n1.out 6 256 Limitation Processing time of the proposed algorithm s 1 second
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
