If you want to memorize the valencies of the elements :- 

-> First, Learn the name of the elements from the periodic table by order. 

-> If you do this you will get the atomic no. i.e. No. of protons. You will also get the No. of electrons. {No. of protons = No. of electrons} 

-> Valency is the No. of valence electrons gained or lost by an element. 

-> Rember the formula i.e. 2(n)^2. This is the formula from which we are able to know that how many electrons can have in an orbit/Shell. 
For e.g.- K is the first orbit. 
Therefore, 2(1)^2 = 2(1) = 2. 
=> K shell can have max. two electrons. 

-> By this we can get the No. of valence electrons and that's the valency. {Because we know atomic No. and the formula, we can find the No. of electrons present in the outermost orbit/shell}.
1 5 1
If u see the perodic table of elements carefully and with sharp focus u will get the trick......
by my thinking there is no any trick behind any thing the think is that in what way we focus on it and learn.....

if u get any help plz mark it as best