Resource pricing in cloud computing has become one of the main challenges for cloud providers. The challenge is determining a fair and appropriate price to satisfy users and resource providers. To determine a fair price, it is necessary to consider the conditions and needs of both parties: provider and user. This research tries to provide a pricing mechanism for cloud computing based on game theory. The proposed mechanism takes into account three factors including fault possibility, interaction between virtual machines, and energy consumption to reach a fair price. In the proposed game, the provider decides on the price of the virtual machine which can be offered to the user on each physical machine and the user decides between the virtual machines offered to run its application. The whole game is implemented as a function of the resource broker component. The proposed mechanism is simulated and evaluated using the CloudSim simulator. Its performance is compared with several previous recent mechanisms. According to the results, the proposed mechanism has been able to determine a more reasonable price for the user and the provider which increases the overall profitability of the cloud system.