Divisible By 11
unknown
csharp
3 years ago
427 B
5
Indexable
public static int DivisibleBy11(int number) { var numbers = number.ToString().ToCharArray(); int coupleCount = 0, oddCount = 0; for (int i = 0; i < numbers.Length; i++) { if (i % 2 == 0) coupleCount += numbers[i] - '0'; else oddCount += numbers[i] - '0'; } return coupleCount - oddCount; }
Editor is loading...