Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # https://www.facebook.com/groups/python/posts/1508202230020336/?__cft__[0]=AZUIx1wejwuzvHy0K7k8yo56G_n5sD1TZYvAuVfJJa0R_H-2Ol2IT3geUFj2pTxiHVePz7P_C01FGoAPM_-EDWQROqrkg5clYchjSzCtiLnVzA64e3jkPZD8ABz7TXq2UV1YXCYLx9mip8iTDIGBa4-t&__tn__=%2CO%2CP-R
- # Trójki Pitagorasa
- import math
- for x in range(2, 100):
- #print(type(sqrt(x + x+1)))
- #if (x + x+1 == sqrt(x + x+1)**2):
- #if (isinstance(sqrt(x + x+1), int)): # nie działą
- # alternatywa 1.
- # funkcja modf
- # https://www.educative.io/answers/how-to-extract-the-fractional-part-of-a-float-number-in-python
- # if (modf(sqrt(x + x+1))[0] == 0):
- # alternatywa 2.
- # przechodzi gdy część dziesiętna floata jest równa zeru po konwersji na str "0"
- # if str(sqrt(x + x+1)).split(".")[1] == "0":
- # alternatywa 3.
- # od liczby rzeczywistej (float) odjąć całkowitą po konwrersji (int)
- if (math.sqrt(x + x+1) - int(math.sqrt(x + x+1))) == 0:
- print(x, x+1, x + x+1)
- #print(sqrt(x + x+1) - int(sqrt(x + x+1)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement