input: from typing import List
  from math import isqrt
  
  def greatest_prime_index_distance(nums: List[int]) -> int:
      """
      You are provided with a list of integers named nums.
  
      Return the maximum gap between the indices of two prime numbers in nums.
  
      Examples:
      >>> nums = [4,2,9,5,3]
      3
      >>> nums = [4,8,2,8]
      0
  
      Constraints:
      1 <= nums.length <= 300,000
      1 <= nums[i] <= 100
      The input guarantees at least one prime number in nums.
      """
output:     
      def is_prime(n):
          if n <= 1:
              return False
          if n in {2, 3}:
              return True
          if n % 2 == 0 or n % 3 == 0:
              return False
          i = 5
          while i * i <= n:
              if n % i == 0 or n % (i + 2) == 0:
                  return False
              i += 6
          return True
  
      primes_indices = [i for i, num in enumerate(nums) if is_prime(num)]
      
      if len(primes_indices) < 2:
          return 0
  
      return primes_indices[-1] - primes_indices[0]
  