Horje
multiplication using arrays Code Example
multiplication using arrays
// basic idea is how would you multiply two number on paper

// 	6534584351565431546351314865641313541354
// 										X  5
// _________________________________________
// 32672921757827157731756574328206567706770 


    public static List<int> Function(string N, int n)
    {
        var num = N.ToCharArray().ToList()
                   .Select(s => Convert
                   .ToInt32(s.ToString()))
                   .ToList();
        num.Reverse();

        // initially remainder is 0
        var remainder = 0;
        for (int i = 0; i < num.Count; i++)
        {
            var temp = num[i] * n + remainder;
            var inString = temp.ToString();

            if (inString.Length > 1)
            {
                num[i] = Convert.ToInt32(inString[1].ToString());
                remainder = Convert.ToInt32(inString[0].ToString());
            }
            else
            {
                num[i]= Convert.ToInt32(inString[0].ToString());
                remainder = 0;
            }
        }
        if(remainder!=0)
        {
            num.Add(remainder);
        }
        num.Reverse();
        return num;
    }
Source: ideone.com




Csharp

Related
change vignette intensity unity Code Example change vignette intensity unity Code Example
meta keywords tag mvc .net core Code Example meta keywords tag mvc .net core Code Example
Create gaps / headers between variables in the unity inspector Code Example Create gaps / headers between variables in the unity inspector Code Example
How to get the world position of the edge of an object? Code Example How to get the world position of the edge of an object? Code Example
c# get last item in list Code Example c# get last item in list Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
15