# Tutor profile: Nicholas R.

## Questions

### Subject: Spanish

Translate the following sentences from English to Spanish: 1. The pretty girl thanked the old man for his advice after they finished eating. 2. The happy couple was astounded to realize that their friends had divorced. 3. The yellow ball accidentally rolled down the hill into the river, the current of which swept it away immediately. Which irregular verbs have a 3-letter conjugation in the 2nd-person, singular, imperative tense? What are the conjugations? What is the meaning of the verb?

1. La chica linda agradece al viejo para su consejo después de acabar comer. 2. La feliz pareja fueron sorprendado cuándo se dieron cuenta de que sus amigos divorciaron. 3. La pelota amarilla se ha rodado la colina al río, cuya corriente se la lleva immediatamente. Hacer - Haz - To make/do Venir - Ven - To come Poner - Pon - To put/place Tener - Ten - To have Salir - Sal - To leave Ver - Ve - To see Ser - Se - To be Dir - Di - To say

### Subject: C++ Programming

Make a function $$maxPrime$$ that accepts an integer $$n$$ and returns its largest prime factor that is not itself, unless $$n$$ is prime.

We can immediately identify 2 properties of the $$maxPrime()$$ method: 1. The function accepts an integer $$n$$ as a parameter. 2. The function returns a prime number, which is an integer, so the type of the function is $$int$$. Therefore, our function will look as follows: $$public\ int\ maxPrime(int\ n)\ \{$$ $$\ \ \ \ \ //body$$ $$\}$$ To find the largest prime factor, we can iteratively decrement possible factors of $$n$$ until we find a number that evenly divides $$n$$. This will require a variable representing the possible factors of $$n$$, and a loop, as follows: $$i=n/2;$$ $$while(i>1)\{$$ $$\ \ \ \ \ if(n\%i==0\ \&\&\ isPrime(i))\{\ return\ n;\}$$ $$\ \ \ \ \ i--;$$ $$\}$$ The largest possible factor of a number is half of that number, so we can initialize $$i$$ to $$n/2$$. Here we check is $$i$$ is a factor of $$n$$ with the first condition in the $$if$$ statement, $$n\%i==0$$. The modulo operator, $$\%$$, returns the remainder of the quotient $$n/i$$. The second condition, $$isPrime(i)$$ returns true if $$i$$ is a prime number. This function has not been defined yet, so we must do that next. The $$isPrime$$ function determines if the integer passed in is prime. Because this is checking for truth, this function is of type $$bool$$. Therefore, our function will look as follows: $$public\ bool\ isPrime(int\ n)\ \{$$ $$\ \ \ \ \ //body$$ $$\}$$ To determine if $$n$$ is prime, similar to the $$maxPrime$$ method, we can iteratively decrement possible factors of $$n$$, testing to see if any number divides $$n$$ evenly. This will require a variable representing the possible factors of $$n$$, and a loop, as follows: $$i=sqrt(n);$$ $$while(i>1)\{$$ $$\ \ \ \ \ if(n\%i==0\)\{\ return\ false;\}$$ $$\ \ \ \ \ i--;$$ $$\}$$ $$return\ true;$$ For the purposes of this exercise, we can assume that the math library $$<cmath.h>$$ is included in this code, thereby allowing us to use the square-root method, $$sqrt()$$. We know that every factor of $$n$$ has a corresponding factor that is complementary with respect to its value as compared to the square-root of $$n$$. For example, the square-root of $$16$$ is $$4$$, and its pairs of factors are $$(1,16)$$, $$(2,8)$$, and $$(4,4)$$, of course. As you can see, for each factor less than the square-root, there is a compliment that is greater than the square-root. Therefore, we can initialize $$i$$ to the square-root of $$n$$ and test all integers less than this number. If we find a number $$i$$ that divides $$n$$ evenly, then $$n$$ is not prime and the function call returns $$false$$. If, however, we test all number $$2,3,\ .\ .\ .\ ,\ sqrt(n)$$ and none divides $$n$$, then $$n$$ is prime and we return $$true$$. Now that we have defined both $$maxPrime$$ and $$isPrime$$, we have our methods, which are as follows: $$public\ int\ maxPrime(int\ n)\ \{$$ $$\ \ \ \ \ i=n/2;$$ $$\ \ \ \ \ while(i>1)\{$$ $$\ \ \ \ \ \ \ \ \ \ if(n\%i==0\ \&\&\ isPrime(i))\{\ return\ n;\}$$ $$\ \ \ \ \ \ \ \ \ \ i--;$$ $$\ \ \ \ \ \}$$ $$\}$$ $$public\ bool\ isPrime(int\ n)\ \{$$ $$\ \ \ \ \ i=sqrt(n);$$ $$\ \ \ \ \ while(i>1)\{$$ $$\ \ \ \ \ \ \ \ \ \ if(n\%i==0\)\{\ return\ false;\}$$ $$\ \ \ \ \ \ \ \ \ \ i--;$$ $$\ \ \ \ \ \}$$ $$\ \ \ \ \ return\ true;$$ $$\}$$

### Subject: Algebra

Find the area of the right triangle whose length and width are equal to the roots of the following expression: $$(\dfrac{2x^3-x^2-13x-6}{x^2-4})(\dfrac{x^2+x-6}{x+3})$$

Step 1: Identify the polynomials in the expression that are easily factorable: $$x^2-4=(x+2)(x-2)$$ $$x^2+x-6=(x+3)(x-2)$$ Step 2: Substitute factored polynomials into expression: $$(\dfrac{2x^3-x^2-13x-6}{(x+2)(x-2)})(\dfrac{(x+3)(x-2)}{x+3})$$ Step 3: Cancel out common factors: $$\dfrac{2x^3-x^2-13x-6}{x+2}$$ Step 4: Use polynomial long division to simplify the quotient: $$(2x+1)(x-3)$$ Step 5: Solve for the roots of the equation, which are found by setting the factors equal to 0: $$2x+1=0$$ $$2x=-1$$ $$x=-\dfrac{1}{2}$$ $$x-3=0$$ $$x=3$$ Step 6: Now the we have our roots, we can find the area of the triangle. $$A=\dfrac{(1)(2)}bh$$ $$A=(\dfrac{1}{2})(\dfrac{1}{2})(3)$$ $$A=\dfrac{3}{4}$$

## Contact tutor

needs and Nicholas will reply soon.