Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- __author__ = 'behemothh'
- def my_func(a):
- s = 0
- k = 0
- while k < (a**3):
- k += 1
- s += k
- return s
- import time
- for test_value in [10, 50, 100, 150, 200, 250]:
- s = my_func(test_value)
- print s,"dette er s"
- print "my_func() with value = {} took {:.2f} milliseconds"
- def primes(n):
- t0 = time.time()
- primfac = []
- d = 2
- while d*d <= n:
- while (n % d) == 0:
- primfac.append(d) # supposing you want multiple factors repeated
- n //= d
- d += 1
- if n > 1:
- primfac.append(n)
- t1 = time.time()
- return primfac,"Dette tok ",(t1-t0)*1000.0," millisekunder"
- print "a) ",primes(438972993803)
- print "b) ",primes(24231186386293)
- print "c) ",primes(6446424082262063)
- print "d) ",primes(2532386475205751977)
- print "e) ",primes(607668475597090743973)
- print "f) ",primes(434220334639935732838391193782579654449762442496152115147965940029674236149760)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement