[ab initio mathematics] The NO. 205 Section Elementary Number theory preliminary

Source: Internet
Author: User

plot summary:
[Machine Xiao Wei] in the [engineer Ah Wei] escorted into the [nine turn Elixir] seventh turn of the cultivation.
This is to be studied [elementary number theory Preliminary].

Drama Start:


Star Calendar May 08, 2016 10:05:37, the Milky Way Galaxy Earles the Chinese Empire Jiangnan Line province.
[Engineer Ah Wei] is working with [machine Xiao Wei] to study [elementary Number theory Preliminary].











<span style= "FONT-SIZE:18PX;"    >710316 can be divisible by 3 710316 can be divisible by 9 710316 cannot be divisible by 11 710316 cannot be divisible by 7 # According to the Law Division of the Division of Sex # is actually not practical, just explain the Rules def TMP (): number = 710316;    Array = numberarray (number);    size = len (array);    #被11整除 array_odd = Array[0:size:2];    Array_even = Array[1:size:2];    #被7整除 array_last3 = number%1000;    Array_front = (number-array_last3)//1000;    #判断被3整除 if sum (array)%3==0:print (' {0} can be divisible by 3 '. Format (number));    Else:print (' {0} cannot be divisible by 3 '. Format (number));    #判断被9整除 if sum (array)%9==0:print (' {0} can be divisible by 9 '. Format (number));    Else:print (' {0} cannot be divisible by 9 '. Format (number));    #判断被11整除 if (sum (array_odd)-sum (array_even))%11 = = 0:print (' {0} can be divisible by 11 '. Format (number));            Else:print (' {0} cannot be divisible by 11 '. Format (number));    #判断被7整除 if (array_last3-array_front)%7==0:print (' {0} can be divisible by 7 '. Format (number));    Else:print (' {0} cannot be divisible by 7 '. Format (number)); #把一个整数的各位数字放入数组 # the Def numberarray (number) is arranged by a single digit: array = []; bit = Len (stR (number));        For I in range (bit): Array.append (NUMBER%10);    number//=10;        #array. reverse (); Return array;</span>








<span style= "FONT-SIZE:18PX;" > #判断一个数是否质数  def Prime (num):      if (num < 2):          return False;            SQR = Int (math.sqrt (num)) +1;        For I in range (2, SQR):          if (num%i==0):              return False;        return True; </span>




<span style= "FONT-SIZE:18PX;" > #最大公约数def gcd (M, N):        m, n = max (M, N), Min (m, n);        i = 1;        While N:            print (' Step ', I, ': ', M, n);            i + = 1;            m, n = n, m% n                    return m</span>



<span style= "FONT-SIZE:18PX;" > #最小公倍数def LCM (M, N):    return M*N/GCD (M, N);</span>


<span style= "FONT-SIZE:18PX;" >>>> 2625.0print (LCM (375,;</span>))



<span style= "FONT-SIZE:18PX;" > #分解质因数  def primefactor (num, lists):      if (num < 2):          lists.append (num);          return lists;      Elif (prime (num) = = True):          lists.append (num);          return lists;      else:              sqr = int (math.sqrt (num)) +1;          i = 2;            While I <= SQR:              if (num% i = = 0 and prime (i) = = True):                  lists.append (i);                  num = num//i;                  break;                            I+=1;          return Primefactor (num, lists); </span>




<span style= "FONT-SIZE:18PX;" >>>> 720 = 2 * 2 * 2 * 2 * 3 * 3 * 5152 = 2 * 2 * 2 * 19813680.0def TMP2 (): Number    = [720];    For j in Range (len (number)):        factors = primefactor (Number[j], []);        Count = len (factors);        s = str (number[j]) + ' = ';                For I in range (count):            s + = str (factors[i]);            if (I < count-1):                s + = ' * ';        print (s);            Print (GCD (720,152));    Print (LCM (720));</span>























<span style= "FONT-SIZE:18PX;" >>>> 21 Euler function value φ (+) = 12.0def Tmp3 (number):    print (' {0} ' Euler function value φ ({0}) = {1} '. Format (numbers, round ( Eulerphi (number), 3))) #欧拉函数def Eulerphi (number):    factors = set (Primefactor (number, []));    factors = sorted (factors);        #print (factors);    phi = number;    For I in range (len (factors)):        Phi *= (1-1/factors[i]);    Return phi;</span>


<span style= "FONT-SIZE:18PX;" >>>> 25 Euler function value φ = 20.0def tmp4 (): For    I in range (1):        if (18**i)%25==1:            print (i);            Break;</span>






<span style= "FONT-SIZE:18PX;" >>>> [4.0, 9.0, 14.0]def Tmp5 ():    result = [];    MoD =;    remain = 6;    quotient = 9;            For I in range (1):                x = (mod*i + remain)/quotient;        If ABS ((int (x))-X) < 1e-6:            result.append (x);        If x > mod: Break            ;    Print (Result);</span>




<span style= "FONT-SIZE:18PX;" >>>> [9.0] #例6def TMP5 ():    result = [];    MoD =;    remain = 1;    quotient =;            For I in range (1):                x = (mod*i + remain)/quotient;        If ABS ((int (x))-X) < 1e-6:            result.append (x);        If x > mod: Break            ;    Print (Result);</span>












<span style= "FONT-SIZE:18PX;" >var s = [' F (a) =e, F (b) =f, F (c) =g ', ' a=-1, e=2; ', ' b=0, f=3; ', '  c=1,  g=6; ', ' f (x) = 2 (x-0) (x-1)/(-1)/(-2) ' , ' +3 (x+1) (x-1)/(1)/( -1) ', ' +6 (x+1) (x-0)/(2)/(1) ',];</span>

<span style= "FONT-SIZE:18PX;" >[58, 238, 418, 598, 778, 958, 1138, 1318, 1498] #孙子定理的变通def tmp6 ():    remain = [2, 3, 4];    MoD = [4, 5, 9];    Count = Len (mod);    Multi = 1;    For I in range (count):        multi *= mod[i];    #直接遍历这个范围    bound = SUM (remain) *multi+1;    result = [];    For I in range (1, bound): for        J in Range (count):            if I%MOD[J]!=REMAIN[J]: Break                ;            If J >= count-1:                result.append (i);        Print (Result);</span>


<span style= "FONT-SIZE:18PX;" >[282, 975, 1668, 2361, 3054, 3747, 4440, 5133, 5826, 6519, 7212, 7905] #孙子定理的变通def tmp6 ():    #模数    mod = [7, 9, 11] ;    #余数    remain = [2, 3, 7];        Count = Len (mod);    Multi = 1;    For I in range (count):        multi *= mod[i];    #直接遍历这个范围    bound = SUM (remain) *multi+1;    result = [];    For I in range (1, bound): for        J in Range (count):            if I%MOD[J]!=REMAIN[J]: Break                ;            If J >= count-1:                result.append (i);        Print (Result);</span>


<span style= "FONT-SIZE:18PX;" >[2111, 4421, 6731, 9041, 11351, 13661, 15971, 18281, 20591, 22901, 25211, 27521, 29831, 32141, 34451, 36761, 39071, 41 381, 43691, 46001] #韩信点兵 # The Flexible def TMP6 () of Sun Tzu's theorem:    #模数    mod = [5, 6, 7, one];    #余数    remain = [1, 5, 4, ten];        Count = Len (mod);    Multi = 1;    For I in range (count):        multi *= mod[i];    #直接遍历这个范围    bound = SUM (remain) *multi+1;    result = [];    For I in range (1, bound): for        J in Range (count):            if I%MOD[J]!=REMAIN[J]: Break                ;            If J >= count-1:                result.append (i);        Print (Result);</span>




















<span style= "FONT-SIZE:18PX;" >2 30 685 25 708 20 7211 15 7414 10 7617 5 7820 0 80# Hundred-watt def TMP8 ():    a =;    b =;    c = n/A;    result = [];        For I in Range (a+1): for J in range (        b+1): for            K in range (c+1):                if (ABS (((i*3 + j*2 + k*0.5)) < 1e-6) and i+j+k = =:                    print (I, J, K);</span>




<span style= "FONT-SIZE:18PX;" > #不定方程def TMP7 ():    #ax + by  = C    #b为大于1的整数    A, B, C = 3, 2, 5;    U, V, I, j = A, B, 0, 1;    R = u%v;    K = J;        While r!=1:        u, v = V, R;        Q = u//v;        R = u%v;        j = i-q*j;        i = k;        K = J;    x = c*k;    y = c* (1-a*k)/b;    Print (x, y);</span>



>>>-34 6.0# indefinite Equation def tmp7 ():    #ax + by  = C    #b为大于1的整数    A, b, C = 2;    U, V, I, j = A, B, 0, 1;    R = u%v;    K = J;        While r!=1:        u, v = V, R;        Q = u//v;        R = u%v;        j = i-q*j;        i = k;        K = J;    x = c*k;    y = c* (1-a*k)/b;    Print (x, y);






The end of this section, to know how to funeral, please see tell.

[ab initio mathematics] The NO. 205 Section Elementary Number theory preliminary

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.