King points gold

= SUM 0 
# . 1 , in order to calculate the cycle . 1 * . 1 + 2 * 2 + . 3 * . 3 + ... + * n- n- 
n- = . 5 
for I in Range ( . 1 , n-+ . 1 ): 
    SUM + = I * I 
Print ( " rotation result: " + STR (SUM)) 


# 2 , to the recursive computation *. 1 . 1 + 2 * 2 + . 3 * . 3 + . 4 * . 4 + ... + n-*n- 
DEF jishuna (K): 
    IF K == 0 :
         return  0 
    the else :
         return K * K + jishuna (K - . 1 ) 


Print ( " Results recursion: " + STR (jishuna (n-)))

 

Guess you like

Origin www.cnblogs.com/littlehb/p/11297912.html