Smart-Contract-Vulnerabilities-DB / Base Sample / costly_pattern / costly_pattern_2.sol
costly_pattern_2.sol
Raw
// SPDX-License-Identifier: GPL-3.0

pragma solidity 0.8.19;

contract sum{
    uint256 variable = 0;

    function calculate(uint256 _value) public view returns(uint256){
        if(_value > 1){
            uint a = variable + 1;
            a++;
            a = a*4;
            return calculate(_value-1);
        }
        else{
            return 1;
        }
    }
}