Домашни - Advanced Loops - Programming Basics с JAVA - Декември 2016 ( 1 до 6 задача)
Задача 1
=========
Задача 2
========
Задача 3
========
Задача 4
========
Задача 5
========
Задача 6
Задача 1
=========
Задача 2
========
Задача 3
========
Задача 4
========
Задача 5
========
Задача 6
зад.7
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication4
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = int.Parse(Console.ReadLine());
            int b = int.Parse(Console.ReadLine());
            while(b!=0)
            {
                var oldB = b;
                b = a % b;
                a = oldB;
            }
            Console.WriteLine("GCD = {0}", a);
        }
    }
}
зад.8
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication4
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            int fact = 1;
            while (n > 1)
            {
                fact = fact * n;
                n--;
            }
           Console.WriteLine(fact);
        }
    }
}
зад.9
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication4
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            int sum = 0;
            do
            {
                sum = sum + n % 10;
                n = n / 10;
            }
            while (n > 0) ;
           Console.WriteLine("Sum of digits: {0}", sum);
        }
    }
}