]> git.leopard-lacewing.eu Git - prjeul.git/commitdiff
func update master
authortreecity <schaeferpm@gmail.com>
Sat, 7 Apr 2012 16:29:38 +0000 (18:29 +0200)
committertreecity <schaeferpm@gmail.com>
Sat, 7 Apr 2012 16:29:38 +0000 (18:29 +0200)
12.py
3.py
6.py
func.py

diff --git a/12.py b/12.py
index 87c8732fbd3e9fd965dcc83d1b399f9d3bdcf8e7..19b529fc7990b58511b1c04ee9897d229117bb5b 100644 (file)
--- a/12.py
+++ b/12.py
@@ -3,7 +3,7 @@ import math
 
 def factor2(n):
     if n<4:
-        return []
+        return {n:1}
     p = func.primes(int(n**.5+1))
     f = {}
     while n>1:
@@ -32,11 +32,15 @@ def catult(seq):
 def possi(test):
     return sum(catult(map(lambda x:test[x],test.keys()))[1:])+1
 
+def devisors(num):
+    test = factor2(num)
+    return sum(catult(map(lambda x:test[x],test.keys()))[1:])+1
+
 
 # Eigene Loesung
 for i in range(3,15000):
-    if(possi(factor2(func.summandielle(i)))>500):
-        print [possi(factor2(func.summandielle(i))), i, func.summandielle(i)],
+    if(possi(factor2(func.summandial(i)))>500):
+        print [possi(factor2(func.summandial(i))), i, func.summandial(i)],
         break
 
 # Phil Buff
@@ -46,7 +50,7 @@ for i in range(10,15000):
     else:
         pos = possi(factor2(i))*possi(factor2((i+1)/2))
     if(pos>500):
-        print [possi(factor2(func.summandielle(i))), i, func.summandielle(i)],
+        print [possi(factor2(func.summandial(i))), i, func.summandial(i)],
         break
 
     
diff --git a/3.py b/3.py
index 08438954588aa4dec879a3c774dfd5fa090feb8e..e1fb70b884a073cef18658c0fd9838bd305ee409 100644 (file)
--- a/3.py
+++ b/3.py
@@ -14,7 +14,7 @@ def primes(n):
 
 def factor(n):
     if n<4:
-        return []
+        return [n]
     p = primes(int(n**.5+1))
     f = []
     while n>1:
diff --git a/6.py b/6.py
index cc6be2e937bc086eed2c65e54c5891183a558379..3570bee0c04e1fb64a1095e2c640014a4332368c 100644 (file)
--- a/6.py
+++ b/6.py
@@ -1,3 +1,3 @@
 import func
 
-print abs(func.summandielle(100)**2 - reduce(lambda x,y:x+y*y,range(1,101),0))
\ No newline at end of file
+print abs(func.summandial(100)**2 - reduce(lambda x,y:x+y*y,range(1,101),0))
\ No newline at end of file
diff --git a/func.py b/func.py
index d943894f70451d31b533a9c8e82149438b00ee08..4d2c589935762098b3c319013dd1ee4949ced4d7 100644 (file)
--- a/func.py
+++ b/func.py
@@ -1,36 +1,36 @@
 import math
 
 # Berechnet die Summe aller vielfachen von base bis max
-def summandielle(max,base=1):
-    max = int(max/base)*base
-    return max*(max+base)/(2*base)
+def summandial(m,base=1):
+    m = int(m/base)*base
+    return m*(m+base)/(2*base)
 
 # Gibt die naechst kleine Fib zu max zurueck
-def fib(max):
+def fib(m):
     a,b = 1,2
-    while b < max:
+    while b < m:
         a,b = b,a+b
     return a
 
 # Gibt die Liste aller Fib zur naechst kleineren Fib von max zurueck
-def fib2(max):
+def fibV(m):
     a = [1, 2]
     i = 1;
-    while a[i] < max:
+    while a[i] < m:
         a.append(a[i] + a[i-1])
         i = i+1
     return a
 
 # Gibt die Summe aller geraden Fib zu max zurueck
-def fibS(max):
+def fibS(m):
     a,b = 1,2
-    sum = 0
-    while b < max:
+    s = 0
+    while b < m:
         a,b = b,a+b
         if a%2 == 0:
-            sum = sum +a
-            
-    return sum
+            s = s +a     
+    return s
+
 # Gibt alle Primzahlen bis n zurueck
 def primes(n):
     if n < 2:
@@ -47,7 +47,7 @@ def primes(n):
 # Gibt alle Primfaktoren bis von n zurueck
 def factor(n):
     if n<4:
-        return []
+        return [n]
     p = primes(int(n**.5+1))
     f = []
     while n>1:
@@ -60,9 +60,9 @@ def factor(n):
     f.sort()
     return f
 
-def factor2(n):
+def factorD(n):
     if n<4:
-        return []
+        return {n:1}
     p = primes(int(n**.5+1))
     f = {}
     while n>1:
@@ -98,4 +98,8 @@ def ebinomial(seq):
             vek[j] = vek[j]+vek[j-1]*i
         vek[len(vek):]=[0]
         
-    return vek[:len(vek)-1]
\ No newline at end of file
+    return vek[:len(vek)-1]
+
+def divisors(num):
+    test = factorD(num)
+    return sum(ebinomial(map(lambda x:test[x],test.keys()))[1:])+1
\ No newline at end of file