# Tutor profile: Andrea W.

## Questions

### Subject: Java Programming

FizzBuzz problem : Write a function in Java that prints the numbers from 1 to 50. But for multiples of three print "Fizz" instead of the number and for the multiples of five print "Buzz". For numbers which are multiples of both three and five print "FizzBuzz." Note: This is a classic example of a question asked in a coding or technical interview for a software engineering position. For students who are looking for employment opportunities in this field, the ability to solve questions like these is crucial.

I have included my solution below and will explain some of the nuances of my solution and other potential solutions underneath the code snippet: public void FizzBuzz() { for (int i = 1; i <= 50; i++) { // loop through all numbers 1 through 50 for printing if (i % 15 == 0) System.out.println("FizzBuzz"); else if (i % 5 == 0) System.out.println("Buzz"); else if (i % 3 == 0) System.out.println("Fizz"); else System.out.println(i); } } The first thing to note is that I am looping over all numbers 1 through 50. Although many loops traditionally start with i=0, I purposely started at i=1 since I only want to loop over the numbers that I want to print or replace with some combination of Fizz and Buzz. However, it is also possible to start your loop at i=0, just make sure you add 1 before printing or checking for divisibility. Another thing to note is how I set up my if statements. In theory, you could split the if/else-if chain into multiple separate if-statements to check for each case, but then you would have the added complexity of having to check that all the other conditions are not satisfied (for instance, if a number is divisible by 15, you don't want to print FizzBuzz and then print Fizz and Buzz separately again, since these numbers satisfy divisibility by 3 and 5 separately as well). It is also significant that I included the check for divisibility by 15 before all other checks in the if/else chain. Had I not done that, I would introduce a bug in the code that would cause behavior like this example: Say I put the divisibility by 5 check before the divisibility by 15 check. Now let's say I'm looking at the number 30. Clearly this number is divisible by 15, so we should print FizzBuzz. But, it is also divisible by 5. The code will look at the first if statement and note that 30 is in fact divisible by 5, so it will print just "Buzz". Since it is an if/else statement, since it already satisfied one condition, it will ignore the rest. So, we will have just printed Buzz and not FizzBuzz, which is a problem. The last note is to make sure to print the number if you are not printing Fizz or Buzz. I know it may sound trivial, but I have had many students in the pass skip this step because they were focused solely on the fizz/buzz problem. So make sure your general case is included as well.

### Subject: Computer Science (General)

FizzBuzz problem : Write a function that prints the numbers from 1 to 50. But for multiples of three print "Fizz" instead of the number and for the multiples of five print "Buzz". For numbers which are multiples of both three and five print "FizzBuzz." Note: This is a classic example of a question asked in a coding or technical interview for a software engineering position. For students who are looking for employment opportunities in this field, the ability to solve questions like these is crucial.

For my solution, I used Java, but my solution would look similar in virtually any coding language. I have included my solution below and will explain some of the nuances of my solution and other potential solutions underneath the code snippet: public void FizzBuzz() { for (int i = 1; i <= 50; i++) { // loop through all numbers 1 through 50 for printing if (i % 15 == 0) System.out.println("FizzBuzz"); else if (i % 5 == 0) System.out.println("Buzz"); else if (i % 3 == 0) System.out.println("Fizz"); else System.out.println(i); } } The first thing to note is that I am looping over all numbers 1 through 50. Although many loops traditionally start with i=0, I purposely started at i=1 since I only want to loop over the numbers that I want to print or replace with some combination of Fizz and Buzz. However, it is also possible to start your loop at i=0, just make sure you add 1 before printing or checking for divisibility. Another thing to note is how I set up my if statements. In theory, you could split the if/else-if chain into multiple separate if-statements to check for each case, but then you would have the added complexity of having to check that all the other conditions are not satisfied (for instance, if a number is divisible by 15, you don't want to print FizzBuzz and then print Fizz and Buzz separately again, since these numbers satisfy divisibility by 3 and 5 separately as well). It is also significant that I included the check for divisibility by 15 before all other checks in the if/else chain. Had I not done that, I would introduce a bug in the code that would cause behavior like this example: Say I put the divisibility by 5 check before the divisibility by 15 check. Now let's say I'm looking at the number 30. Clearly this number is divisible by 15, so we should print FizzBuzz. But, it is also divisible by 5. The code will look at the first if statement and note that 30 is in fact divisible by 5, so it will print just "Buzz". Since it is an if/else statement, since it already satisfied one condition, it will ignore the rest. So, we will have just printed Buzz and not FizzBuzz, which is a problem. The last note is to make sure to print the number if you are not printing Fizz or Buzz. I know it may sound trivial, but I have had many students in the pass skip this step because they were focused solely on the fizz/buzz problem. So make sure your general case is included as well.

### Subject: Calculus

Assume that a car traveling along a line has position modeled by f(x)=x^2-5*x+8+2^x. Find a function modeling the velocity of the car.

Let us take the derivative of f(x): f'(x)=2*x-5+(ln 2) * 2^x Here, we used two different rules: the Product Rule and Exponent Rule of derivation. We used the Product Rule to evaluate the derivative of the expression x^2-5*x+8 to get 2*x-5, and the Exponent Rule to evaluate the derivative of the expression 2^x to get (ln 2) * 2^x. We know that the derivative of the sum of two expressions is the sum of their derivatives, so we can simply add these expressions to find the derivative of f(x). Since f(x) represents the position of the car, f'(x) represents its velocity. So now we are done.