### given a prime, finding where it is the list of primes

I'm writing a program that gives as an output the prime factorization of a number, and then I'm putting the primes into a matrix based on what prime number it is, (i.e 541 is the 100th prime, so if 541^2 divides my integer, then there would be a 2 in the 100th spot of my vector that represents my number)

Is there a function that takes as its input a prime and gives as an output where it is in the list of primes.
(i.e we want f(541) = 100)

Thanks in advance!