Advertisement
Guest User

Untitled

a guest
Jul 26th, 2013
29
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. def findAB (c):
  2. c = c multiplied by 100
  3. for a in 0..9: # or possibly 1..9
  4. for b in 0..9:
  5. set ab to a multiplied by 10 plus b
  6. if (ab multiplied by ab) is equal to (c plus ab):
  7. return (a,b)
  8. return nothing
  9.  
  10. c | a | b | ab | return
  11. -----+-----+-----+------+----------
  12. | | | |
  13. | | | |
  14. | | | |
  15. | | | |
  16.  
  17. for a in range(1,10):
  18. for b in range(10):
  19. ab = a*10+b
  20. ab2 = ab*ab
  21. if (ab2 % 100) == ab:
  22. print "a=",a,", b = ",b
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement