C # solving a primary school Olympics question

Source: Internet
Author: User

Primary Olympics question:

On the blackboard, the name is like 8888 ...... The number of 88 is erased from the last digit. Multiply the previous digit by 2, and then add the erased digit to continue the operation on the new number. What is the final result?

Using system;
Using system. Collections. Generic;
Using system. LINQ;
Using system. text;

Namespace consoleapplication1
{
/// <Summary>
/// On the blackboard, the name is shown as 8888 ...... The number of 88 is erased from the last digit. Multiply the previous digit by 2, and then add the erased digit to continue the operation on the new number. What is the final result?

/// Master code♂Luo Yun
/// </Summary>
Class Program
{
Static void main (string [] ARGs)
{

Int64 tem2 = 0;
Int64 TEM = 88888888;
While (TEM> 10)
{
Tem2 = (int64) (TEM/10) * 2 + (TEM % 10 );
TEM = tem2;
}
Console. Write (TEM. tostring ());
// Output 8
Console. Read ();
}
}
}

 

 

Primary Olympics question:

On the blackboard, the name is like 8888 ...... The number of 88, each time a last digit is erased, the previous number is multiplied by 2, and then the last digit is erased, the new number is continued, what is the final number?

 

Using system;
Using system. Collections. Generic;
Using system. LINQ;
Using system. text;

Namespace consoleapplication1
{
/// <Summary>
/// On the blackboard, the name is shown as 8888 ...... The number of 88, each time a last digit is erased, the previous number is multiplied by 2, and then the last digit is erased, the new number is continued, what is the final number?
/// Write by Master♂Luo Yun
/// </Summary>
Class Program
{
Static void main (string [] ARGs)
{

Int64 tem2 = 0;
Int64 TEM = 88888888;
While (TEM> 10)
{
Tem2 = (int64) (TEM/10) * 2 + (TEM/10 );
// Tem2 = (int64) TEM/10*2 + (TEM-TEM/10*10)
TEM = tem2;
}
Console. Write (TEM. tostring ());
// Output 3
Console. Read ();
}
}
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.