int N = 2345;
var digitArray = N.ToString().ToCharArray();
int multiplicationSum = 1;
foreach (char digit in digitArray)
{
mu
Assuming you don't need to deal with negative numbers, it seems doing it mathematically would make a lot more sense
int N = 2345;
int multiplicationSum = 1;
while(N!=0)
{
multiplicationSum = multiplicationSum * (N%10);
N = N/10;
}
var sum = 0;
while(multiplicationSum!=0)
{
sum = sum + (multiplicationSum%10);
multiplicationSum = multiplicationSum/10;
}
References:
% operator
The % operator computes the remainder after dividing its first operand by its second
/ operator:
When you divide two integers, the result is always an integer. For example, the result of 7 / 3 is 2