Introduction

Welcome to another exciting session! In today's lesson, we face a unique coding challenge using Kotlin. We will traverse the digits of a number using a while loop and a specific condition. You will hone your skills in working with loops and conditional statements, both of which are fundamental building blocks of programming in Kotlin. Shall we begin?

Task Statement

Our mission today is somewhat mind-twisting! We need to create a function that operates on an input integer to calculate the sum of its even-numbered digits. However, we won't convert this integer to a String at any point during this process. For example, given an integer n with a value of 4625, our output should be 12, which is the sum of the even digits 4, 6, and 2.

Remember, n will always be a positive integer that falls within the range from 1 to 100,000,000. Are you ready for the challenge? Awesome! Let's get started!

Solution Building: Step 1

We begin by setting up the basic structure for our function. In this step, we define a variable, , that will accumulate the sum of the even digits.

Sign up
Join the 1M+ learners on CodeSignal
Be a part of our community of 1M+ users who develop and demonstrate their skills on CodeSignal