# Tutor profile: Albert P.

## Questions

### Subject: Java Programming

Find the sum of the integers that are divisible by 2 up to 100.

We can check if a number is divisible by two by checking if its remainder is equal to zero. In Java programming we can either use the division or mod operator. The portion of Java code that can check if a number is divisible by two can be seen below: int x = 50; if (x % 2 == 0) { // x is divisible by 2 } The modulus operator evaluates the remainder in numeric division. If the result of the modulus operator equals 0 then we know that the number (in this case 'x' is divisible by 2). Next, we need to iterate from 1 to 100 and sum up the values that are divisible by 2. First we will focus on iterating from 1 to a 100. We can use a for loop to accomplish this. A for loop will iterate from a beginning and ending index. We can use our conditional statement above inside of our for loop to determine if a number is divisible by 2. for (int x = 1; x <= 100; x++) { if (x % 2 == 0) { // x is divisible by 2 } } Next, we will need to sum up the values that are divisible by 2. int sum = 0; for (int x = 1; x <= 100; x++) { if (x % 2 == 0) { sum += x; } } The sum += x expression will take the sum and add it to x. It is the equivalent of sum = sum + x. Lastly, we will need to put our code within a Java class. The code can be seen below. public class SumDivisibleByTwo { public static void main(String[] args) { int sum = 0; for (int x = 1; x <= 100; x++) { if (x % 2 == 0) { sum += x; } } System.out.println("The sum of numbers divisible by 2 up to a 100 is: " + sum); } } We will need to paste the above code within a .Java with a name of SumDivisibleByTwo. The final name should look like SumDivisibleByTwo.java. Run the program by running the following commands. javac SumDivisibleByTwo.java java SumDivisibleByTwo We can see the following output: The sum of numbers divisible by 2 up to a 100 is: 2550

### Subject: Calculus

Find the derivative of f(x) = x^2.

The derivative for exponents can be found by applying the below equation to f(x). lim h -> 0 f(a + h) - f(a) / h By applying the above formula (substituting 'a + h' and 'a' into the equation) we get the following. lim h -> 0 (a + h)^2 - a^2 / h = lim h -> 0 ((a^2 + 2ah + h^2) - a^2) / h = lim h -> 0 (2ah + h2) / h From here we can factor out an h. lim h -> 0 h(2a + h) / h = lim h -> 0 (2a + h) In the equation above, as h goes zero we will get 2a. lim h -> 0 (2a + h) = 2a Thus, the derivative of f(x) = x^2 is equal to 2x. f'(x) = 2x

### Subject: Statistics

Adam flips a coin three times. What is the probability that he gets at least two heads (order does not matter)?

We will mark each flip condition with an 'H' to represent heads and a 'T' to represent tails. If Adam flips the coin three times he will have different possible outcomes each time. He could receive the following results. HHH HHT HTH THH TTT TTH THT HTT By looking at the results, we can see that Adam can get heads by HHH, HHT, HTH or THH. The probability of getting a heads is 0.5. Similarly, the probability of getting a tails is 0.5. Thus, the probability of getting HHH is equal to 0.5 X 0.5 X 0.5. The probability of getting HHT is equal to 0.5 X 0.5 X 0.5. The probability of getting HTH is equal to 0.5 X 0.5 X 0.5. Lastly, the probability of getting HHH is equal to 0.5 X 0.5 X 0.5. HHH = (0.5)(0.5)(0.5) = 0.125 HHT = (0.5)(0.5)(0.5) = 0.125 HTH = (0,5)(0,5)(0.5) = 0.125 THH = (0.5)(0.5)(0.5) = 0.125 In all these cases (HHH, HHT, HTH and THH) we receive two heads. Thus, we must sum all these outcomes and get our probability. P(atleast 2 heads) = 0.125 + 0.125 + 0.125 + 0.125 = 0.5

## Contact tutor

needs and Albert will reply soon.