login about faq

Due to the large amount of spam accounts, we temporarily disabled new user sign ups. To override this, email newuser.lgqa@gmail.com and an admin will determine if you are permitted to join


Hey,

So as usual we don't really have much to do right now so we started multiply one by two until we could no more. The only problem is that we don't know if our answers are right after a certain number since our calculators start showing the e+01 at the end which makes to number invalid to check our answers.

I know that it is possible to calculate with a string (bundle of characters not what girls wear :P) but now my script says that 16*2 = 122 which is definitely not right but when you split it into 12 and 2 you only need to do the 2 * 10 to get 20 and add the 12 to get 32.

This is my current script in C# (but any code will do)

        string last = "1";
        int m = 2;

        while (true)
        {
            String newStr = "";
            int nextAdd = 0;
            foreach (char c in last)
            {
                int n = int.Parse(c.ToString());
                n = (n+nextAdd) * m;
                if (n < 10)
                {
                    nextAdd = 0;
                }
                while (n > 10)
                {
                    //Console.WriteLine(n);
                    n -= 10;
                    nextAdd++;
                }

                //Console.WriteLine(n.ToString());
                newStr = n.ToString() + newStr;

                //Console.WriteLine(newStr);
            }
            if (nextAdd != 0)
            {
                newStr = nextAdd.ToString() + newStr;
            }

            Console.WriteLine(newStr);
            last = newStr;

            Thread.Sleep(500);
        }

What am I doing wrong?

asked Sep 30 '11 at 07:41

nitrocrime's gravatar image

nitrocrime
3.6k6477126

Be the first one to answer this question!
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported


Join Us in the Chat Room

Tags:

×125
×28
×16
×5
×2
×1

Asked: Sep 30 '11 at 07:41

Seen: 407 times

Last updated: Sep 30 '11 at 07:41