CSCI 102 - Fall 2023 Fundamentals of Computation

#include <iostream>
#include <string> //includes string.h header file

using namespace std;

int main()
{
  //define and initialize two int variables
  int x = 0;
  int y = 1;

  //while executes as long at least one of x%5 ==0 or y%64==0 returns false
  //1st  loop:
       //0%5==0 is true but 1%64==0 is false so loop executes
	// x set to 1
	//y set to 2
  //2nd loop:
	//1%5==0 is false so loop executes
	//x set to 2
	//y set to 4
  //3rd loop
	//2%5==0 is false so loop executes
	//x set to 3
	//y set to 8
  //4th loop
	//3%5==0 is false so loop executes
	//x set to 4
	//y set to 16
  //5th loop
	//4%5==0 is false so loop executes
	//x set to 5
	//y set to 32
  //6th loop
	//5%5==0 is true but 32%63==0 is false so loop executes
	//x set to 6
	//y set to 64
  //7th loop
	//6%5==0 is false so loop executes
	//x set to 7
	//y set to 128
  //keep going until x is 10, in general y = 2^(x)
  //so when x is 10 y will be 1024
// since 10%==0 is true and 1024%64==0 is true the ! flips the && expression to false and loop exits
  while (!((x % 5 == 0) && (y % 64 == 0)))
  {
    //x incremented
    x++;

    // y set to y*2
    y *= 2;
  }

  //10 1024 is printed to screen
  cout << x << " " << y << endl;
  return 0;
}