JavaScript: Check whether a given positive number is a multiple of 3 or a multiple of 7
JavaScript Basic: Exercise-25 with Solution
Check if Number is Multiple of 3 or 7
Write a JavaScript program to check whether a given positive number is a multiple of 3 or 7.
This JavaScript program checks if a given positive number is a multiple of either 3 or 7. It uses the modulo operator (%) to determine if the number is divisible by 3 or 7 without any remainder. If the result is 0 for either operation, it means the number is a multiple of 3 or 7, respectively.
Visual Presentation:

Sample Solution:
JavaScript Code:
Output:
true true false false
Live Demo:
Flowchart:

ES6 Version:
For more Practice: Solve these Related Problems:
- Write a JavaScript program that checks if a given number is a multiple of 3 or 7, but not both.
- Write a JavaScript program that determines if any number in an array is exclusively a multiple of 3 or 7.
- Write a JavaScript program that verifies if a positive integer is a multiple of either 3 or 7, prioritizing the smaller multiple if both apply.
Improve this sample solution and post your code through Disqus.
Previous: JavaScript program to create a new string from a given string with the first character of the given string added at the front and back.
Next: JavaScript program to create a new string from a given string taking the last 3 characters and added at both the front and back.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.