In this paper we present a method to get the prime counting function p(x) and other arithmetical functions than can be generated by a Dirichlet series, first we use the general variational method to derive the solution for a Fredholm Integral equation of first kind with symmetric Kernel K(x,y)=K(y,x), after that we find another integral equations with Kernels K(s,t)=K(t,s) for the Prime counting function and other arithmetical functions generated by Dirichlet series, then we could find a solution for π(x) and \( \sum_{n \le x} a(n) = A(x) \), solving δJ[ϕ]=0 for a given functional J, so the problem of finding a formula for the density of primes on the interval [2,x], or the calculation of the coefficients for a given arithmetical function a(n), can be viewed as some “Optimization” problems that can be attacked by either iterative or Numerical methods (as an example we introduce Rayleigh-Ritz and Newton methods with a brief description) Also we have introduced some conjectures about the asymptotic behavior of the series \( \Xi_n(x) = \sum_{p \le x} p^{\,n} = S_n(x)\ \) for n>0 , and a new expression for the Prime counting function in terms of the Non-trivial zeros of Riemann Zeta and its connection to Riemman Hypothesis and operator theory.