1. 41.Py

    n=2992
    def py(n,m):
        total = 0
        while n>0:
            total+=n%m
            n=n/m
        return total
    print py(n,10)==py(n,16)==py(n,12) and "Yes" or "No"
    
    read more
  2. 34.The password generated

    a = 1
    b = 77
    x = 1
    y = 14
    
    lister, ans, a = [], [], a%b*10
    while a not in lister:
        lister.append(a)        # 1. not includes x of x.123456
        ans.append(a // b)
        a = (a % b)*10
    
    nolooplen = lister.index(a) # when the iteration appears in ans
    looplen = len(ans ...
    read more
  3. 33.Big power operation

    a=9
    n=50
    def pow_mod(a,n,mod):  # a**50=(a**2)**25, a**25=(a**2)**12*a,
        res = 1
        while n > 0 :
            if n % 2 == 1:  # if n is odd, extract new_a%mod and multiply res
                res = res * a % mod
            a = a * a % mod # 1.a=new_a ...
    read more

« Page 17 / 21 »

blogroll

social