Project Euler

Problem 29: Distinct powers

How many distinct terms are in the sequence generated by a^b for 2 ≤ a ≤ 100 and 2 ≤ b ≤ 100? Run this solution at repl.io here.

      
        nums = []
        for a in range(2,101):
          for b in range(2,101):
            nums.append(a**b)

        # dictionaries can only have unique keys,
        # hence all duplicates are removed
        dict1 = {i for i in nums}

        print(len(dict1))
      
    

back to code menu