Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function dividedByThree(num) {
- var sumOfDigits = 0;
- while (num > 0) {
- sumOfDigits += num % 10;
- num = Math.floor(num / 10);
- }
- if (sumOfDigits % 3 == 0) {
- console.log("the number is divided by 3 without remainder");
- } else {
- console.log("the number is not divided by 3 without remainder");
- }
- }
- dividedByThree(12);
- dividedByThree(189);
- dividedByThree(591);
- dividedByThree(13);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement