23. JavaScript Program to find Numbers Divisible by both 3 and 7 from 1 to 100 numbers.
How does this program work?
- In this program we are going to learn about how to find the numbers which are divisible by both 3 and 7 from 1 to 100 numbers using JavaScript.
- When the number is divided by both 3 and 7, we use the remainder operator % to compute the remainder.
- If the remainder is zero, then that number is divisible of both 3 and 7.
- After doing this for each value, then we get the numbers from 1 to 100.
Here is the code
<html>
<head>
<title>JavaScript program to print the numbers which are divisible by both 3 and 7 from 1 to 100</title>
</head>
<body>
</body>
<script type="text/javascript">
for(i = 1; i <= 100; i++)
{
if(i%3 == 0 && i%7 == 0)
{
document.write(i+"</br>");
}
}
</script>
</html>