fbinnzhivko

Largest Product of Digits

May 15th, 2016
307
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.60 KB | None | 0 0
  1. using System;
  2. class Largest_Product_Of_Digits
  3. {
  4.     static void Main()
  5.     {
  6.         string input = Console.ReadLine();
  7.         int Product = 0;
  8.         int currentProduct = 1;
  9.  
  10.         for (int i = 0; i < input.Length - 5; i++)
  11.         {
  12.             for (int j = i; j < i + 6; j++)
  13.             {
  14.                 currentProduct *= Convert.ToInt32(input[j] - 48);
  15.             }
  16.             if (currentProduct > Product)
  17.             {
  18.                 Product = currentProduct;
  19.             }
  20.             currentProduct = 1;
  21.            
  22.         }
  23.         Console.WriteLine(Product);
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment