Advertisement
BobMe

Determine If Pythag

Apr 23rd, 2019
258
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. -- Determine If a pythag is actually a pythag. I know, this is simple and easy... TO JUSTIFY THAT, I had a very long math assignment assigned by my math teacher about determining if something is a pythag or not. Making a script would be quicker so uh, here you go have a blast to whoever is reading this.
  2.  
  3. function is_pythag(a,b,c)
  4. local aa = a*a
  5. local bb = b*b
  6. local cc = c*c
  7. if aa + bb == cc then
  8. return {true,aa+bb,cc}
  9. else
  10. return {false,aa+bb,cc}
  11. end
  12. end
  13.  
  14.  
  15. g = is_pythag(3,4,5)
  16.  
  17. if g[1] == true then
  18. bol = true
  19. else
  20. bol = false
  21. end
  22.  
  23. print("Is pythag : "..tostring(bol).."\n"..g[2].." = "..g[3])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement