Introduction

Welcome! In today's lesson, we'll dive into a fascinating coding challenge that revolves around traversing the digits of a number using a while loop under a specific condition. You will have the chance to practice and refine your skills in working with Scala's loops and conditional statements, which are fundamental concepts in programming. Are you ready to get started? Let's jump in!

Task Statement

Our objective today is to create a function that operates on an integer input. While the task may appear straightforward, it requires some cleverness. Here’s the challenge: given an integer, n, calculate and return the sum of its even digits without converting n into a string. For example, if n is 4625, the output should be 12, as the sum of the even digits 4, 6, and 2 equals 12.

Keep in mind that n will always be a positive integer between 1 and 10^8. Ready to tackle this challenge? Fantastic! Let’s begin!

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