The nonlocal theory is commonly applied for nanomaterials due to its capability in considering size influences. Available studies have shown that the differential version of this theory is not suitable for some problems such as bending of cantilever nanobeams, and the integral version must be used to avoid obtaining inconsistent results. Therefore, an attempt is made in this paper to propose an efficient variational formulation based on the integral nonlocal model for the analysis of nanobeams. The formulation is developed in a general form so that it can be used for arbitrary kernel functions. The nanobeams are modeled using the Bernoulli-Euler beam theory, and their bending behavior is analyzed. Derivation of governing equations is performed according to an energy-based approach. Also, a numerical approach based on the Rayleigh-Ritz method is developed for the solution of problem. Moreover, the results of integral and differential models are compared. It is revealed that by the proposed numerical solution, the paradox in the behavior of nanocantilever is resolved.