Question: 4.1 Background on heavy numbers 4.1.1 The heavy sequence A sequence of numbers (the heavy sequence) yoyy2y3... Yn... is defined such that each number is

4.1 Background on heavy numbers 4.1.1 The heavy sequence A sequence of numbers (the heavy sequence) yoyy2y3... Yn... is defined such that each number is the sum of digits squared of the previous number, in a particular base. Consider numbers in base 10, with yo = 12 The next number in the sequence is y = 12 + 22 = 5 The next number in the sequence is y2 = 52 = 25 The next number in the sequence is y3 = 22 + 52 = 29 4.1.2 Heaviness It turns out that for each number yo and base N, the heavy sequence either converges to 1, or it does not. A number whose sequence converges to 1 in base N is said to be "heavy in base N" 4.2 Program requirements Write a program 'heavy.cpp that reads a number y and a base N from the command line (both of which are written in base-10 notation) and returns whether that number y is heavy in the base N provided. The return code of this program should be 1 if the number is heavy, and 0 if the number is not heavy. Here are examples: > heavy 4 10 > echo $? @ > heavy 2211 10 > echo $? > heavy 23 2 > echo $? > heavy 10111 2 > echo $? > heavy 12312 4880 > echo ? 4.2.1 Value Ranges The number y will always be storable as a normal int, and the base N will also be storable as a normal int. The number y will always be non-negative, and the base N will always satisfy 2
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
