why check all primes under the root of an interger? I am in high school and I need to factorize numbers. My teacher told me to check all numbers which are smaller than the root of the number I want to factorize. This seems to work just fine, but I do not know why it works and neither does my teacher.
Is there someone here who knows why this trick works?

The other elementary method, usually attributed to Fermat, is to check the squares slightly larger than $n$ and see if the difference is also a square. This works because $$ a^2 - b^2 = (a-b)(a+b).  $$
The example I remember reading was a contest in Russia, they were asked simply to factor $8051.$ The person writing the story tried small primes and could not finish when time was up. However, $8100 = 90^2$ and $8100 - 8051 = 49 = 7^2,$ so
$$ 8051 = 8100 - 49 = 90^2 - 7^2 = (90 - 7)(90 +7) = 83 \cdot 97.  $$ As both $83$ and $97$ are primes, that is a complete factorization. 
Your method, often called trial division, quickly finds small prime factors, if there are any. Fermat's method, which requires that you be quick and sure with squares, rapidly finds factors near $\sqrt n,$ which may not be prime already, so further work may be required. 
