Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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 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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Excel As Your Database

Authors: Paul Cornell

1st Edition

1590597516, 978-1590597514

More Books

Students also viewed these Databases questions

Question

=+4 What are non-union workers representations?

Answered: 1 week ago