CM 1.4 Algorithms MrG 2011.0922

3711 days ago by calcpage123

def countDigits(n): count=1 power=10 while power<=n: count=count+1 power=power*10 return count countDigits(523123) 
       
\newcommand{\Bold}[1]{\mathbf{#1}}6
\newcommand{\Bold}[1]{\mathbf{#1}}6
def p(n): k=0 while n%2==0: k=k+1 n=n/2 return k p(14) 
       
\newcommand{\Bold}[1]{\mathbf{#1}}1
\newcommand{\Bold}[1]{\mathbf{#1}}1
#1) addition, subtraction, multiplication, division, .... 
       
#2) def s(n): return sum(range(1,n+1)) s(5) 
       
\newcommand{\Bold}[1]{\mathbf{#1}}15
\newcommand{\Bold}[1]{\mathbf{#1}}15
#3) def div(m,n): q=0 while m>=n: m=m-n q=q+1 return (q,m) div(154,5) 
       
\newcommand{\Bold}[1]{\mathbf{#1}}\left(30, 4\right)
\newcommand{\Bold}[1]{\mathbf{#1}}\left(30, 4\right)
#4) def pow3(x): p=1 for i in range(x): p=p*3 return p pow3(5) 
       
\newcommand{\Bold}[1]{\mathbf{#1}}243
\newcommand{\Bold}[1]{\mathbf{#1}}243
#5) def p(n): k=0 while n%2==0: k=k+1 n=n/2 return k p(80) 
       
\newcommand{\Bold}[1]{\mathbf{#1}}4
\newcommand{\Bold}[1]{\mathbf{#1}}4