ACM (UVa) : 10922


2 the 9s

Data type:
Integer / Long Integer and String // depends

Algorithm:

Add the digits and if the Summation is divisible by 9 then Degree+=1. After a division, check whether the summation is greater than 9, if so then continue the process, otherwise stop.

Critical input:
99999999999999999999999999999999999999999999999999 >>> [50 digits]
123456789741852963

Critical output:
99999999999999999999999999999999999999999999999999 is a multiple of 9 and has 9-degree 2.
123456789741852963 is a multiple of 9 and has
9-degree 2.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s