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

find a pair of square numbers witch give a total of 125
The least common denominator of two fractions is 28. If you subtract the two denominators, their difference is 10. What are the denominators?
Which component of the earth's atmosphere is decreased due to photosynthesis?
what did karl marx do for the russian revolution?
Russia’s rise as a nation is a story of influences from north, east, south, and west, and of powerful and ambitious rulers. Describe the influence of two of the
What is the digit in the one place is the sum of the digit in a dozon I know it is 12 but do I put it in on place value or the 2 or the 1 in the ones in place v
The north africian maghreb states , dominated by the atlas mountains,do not include
Why is HIV the most variable virus known to science?
In which modern country was the Olmec civilization located? Mexico United States Brazil Peru
what are the steps to write 36/10 as a decimal