Циклы for, while и do.while - C#
Формулировка задачи:
Нужно передать программу с for в while и do...while
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
int n = 17;
int factorial = 1;
for (int i = 2; i <= n; i++)
{
factorial = factorial * i;
}
Console.WriteLine("Factorial iz " + n + " = " + factorial);
Console.Read();
}
}
}Решение задачи: «Циклы for, while и do.while»
textual
Листинг программы
int n = 17;
Int64 factorial = 1;
int i=1;
do
{
factorial = factorial * i;
i++;
} while (i < n);