chocolatejoif44 chocolatejoif44
  • 06-08-2020
  • Computers and Technology
contestada

Display all the natural numbers from 1 to 100 that are exactly divisible by 3 and 7 using FOR … NEXT. Without using Mod

Respuesta :

tonb
tonb tonb
  • 07-08-2020

Answer:

FOR i% = 1 TO 100

 IF ((i%\3) = i%/3) AND ((i%\7) = i%/7)  THEN

   PRINT i%

 END IF

NEXT i%

Explanation:

Of course using MOD would be cleaner, but another way to check if a number is integer divisable is to compare the outcome of an integer division to the outcome of a floating-point division. If they are equal, the division is an integer division.

The program outputs:

21

42

63

84

Answer Link

Otras preguntas

is 4/8 closer to 0 or 1 and why
What is tuft hair that is standing up or growing in a different direction?
A car starts from rest and accelerates uniformly over a time of 5.21 seconds for a distance of 110 meters. Determine the acceleration of the car
Immigrants from which of the following countries would have faced the greatest restrictions during the late 19th century and early 20th century? A.Ireland B.Chi
A recipe for a vegetable dish contains a total of 924 calories the dish to serve six people how many calories are in each serving
How do you solve for x: 1/3x-5/9=5/6x
Can you tell that there is no solution for a system by just looking at the equation
What is a catchy slogan to help people remember the difference between weathering and erosin
Solve the equation in the complex number system X^4-2x^2-3=0
what two numbers add up to -7 but multiply to -18
good job