KCE / Java

Java Programming Language
0 stars 3 forks source link

CoreTask#6: Riley - Submit Your Code #31

Open ErSKS opened 5 years ago

ErSKS commented 5 years ago

A Riley number is an integer whose digits are all even. For example 2426 is a Riley number but 3224 is not. Write a function named isRiley that returns 1 if its integer argument is a Riley number otherwise it returns 0. The function signature is int isRiley (int n)

sapencio commented 3 years ago

public static int isRiley(int n){ while (n > 0){ int digit = n % 10; if (digit % 2 != 0) return 0; n = n / 10; } return 1; }