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

Which inequality is represented by the number line graph? A) x > -6 B) x < -6 C) x ≥ -6 D) x ≤ -6
Help me please part of speech
47 points!!!!!! if one zero is irrational, the other zero is: -ration -irrational -non real
Factorise c²-c-2 ?????????
how is the periodic table of the elements arranged a) alphabetically b)in a neat grid with 11 rows and 10 columns c) by aligning groups with common propertie
9 passengers in 3 cars = passengers per car
What is the name of the above hydrocarbon?
The National Center for Education Statistics surveyed a random sample of 4400 college graduates about the lengths of time required to earn their bachelor’s degr
f(x) = x^2. What is g(x)?
A piece of iron metal is heated to 155 degrees C and placed into a calorimeter that contains 50.0 mL of water at 18.7 degrees C. The temperature of the water r