[PHP] Add all previous numbers in a for loop
#6

Quote:
Originally Posted by benjaminjones
Посмотреть сообщение
Until three, you can make them static, after that simple current number * 2;
Код:
            Console.WriteLine(1);
            Console.WriteLine(2);
            Console.WriteLine(3);
            var res = 3;
            for (int i = 0; i < 7; i++)
            {
                res *= 2;
                Console.WriteLine(res);
            }
It's actually not multiplied by 2, it's add all previous numbers on each loop.
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)