taxiCab.py 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. # Copyright (C) 2020, 2019 Girish M
  2. # This program is free software; you can redistribute it and/or modify
  3. # it under the terms of the GNU General Public License as published by
  4. # the Free Software Foundation; either version 3 of the License, or
  5. # (at your option) any later version.
  6. #
  7. # This program is distributed in the hope that it will be useful,
  8. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. # GNU General Public License for more details.
  11. #
  12. # You should have received a copy of the GNU General Public License
  13. # along with this program; if not, write to the Free Software
  14. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  15. # MA 02110-1301, USA.
  16. #
  17. n = input("enter a positive number till which taxi cab numbers need to be generated:")
  18. i = 1
  19. a = 1
  20. b = 1
  21. p = 1
  22. q = 1
  23. while i != n:
  24. '''find out whether 'i' is a taxi cab number and print it'''
  25. while a != n:
  26. if a != b:
  27. while b != n:
  28. if b != p:
  29. while p != n:
  30. if p != q:
  31. while q != n:
  32. if q != a:
  33. if (a**3 + b**3) == (p**3 + q**3):
  34. print("Taxi cab number is: ", i)
  35. q = q+1
  36. p = p+1
  37. b = b+1
  38. a = a+1
  39. i = i+1