Advertisement
Magnus_Engstroem

3 og 4, 37-38

Sep 18th, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.00 KB | None | 0 0
  1. #%%
  2. #3
  3. a = float(input("Side 1 = "))
  4. b = float(input("Side 2 = "))
  5. c = float(input("Side 3 = "))
  6.  
  7. if a>b>c or a>c>b:
  8.     if a**2 == b**2 + c**2:
  9.         print("Tallene er pytagoreiske tripler!")
  10.     else:
  11.         print("Tallene er ikke pytagoreiske tripler")
  12. elif b>a>c or b>c>a:
  13.     if b**2 == a**2 + c**2:
  14.         print("Tallene er pytagoreiske tripler!")
  15.     else:
  16.         print("Tallene er ikke pytagoreiske tripler")
  17. else:
  18.     if c**2 == b**2 + a**2:
  19.         print("Tallene er pytagoreiske tripler!")
  20.     else:
  21.         print("Tallene er ikke pytagoreiske tripler")
  22.  
  23. #%%      
  24. #4
  25. tall = int(input("Faktorisering av det naturlige tallet: "))
  26.  
  27. print("Alle tall man kan dele " + str(tall) + " pƄ: ")
  28. print("1")
  29. for i in range(2, (tall + 2)//2):
  30.     if tall%i == 0:
  31.         print(i)
  32. print(tall)
  33.  
  34. print("Primtallsfaktorene til " + str(tall))
  35. tall2 = tall
  36. j = 2
  37. while j <= tall2:
  38.     if tall2 % j == 0:
  39.         print(j)
  40.         tall2 = tall2/j
  41.         j = 2
  42.     else:
  43.         j = j+1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement