1. Create a function to calculate the factorial of a given number (using for cycle).
2. Create a function to calculate the factorial of a given number using a while cycle.
3. Create a function that will take two vectors. The two vectors are heights and diameters. The function should return the average height of the trees whose diameters is above the median diameter. Your function needs to check if the vectors are the same size, otherwise, it should return a warning or an error.