> For the complete documentation index, see [llms.txt](https://chihaolu.gitbook.io/all-in-one-solidity/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://chihaolu.gitbook.io/all-in-one-solidity/part-i-basic/chapter-4-liu-cheng-kong-zhi-selection-and-repetition/for.md).

# 【For】

迴圈語法也和其他程式語言一模一樣。

```solidity
pragma solidity ^0.8.11;

contract MyContract {
    uint[] numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];

    function countEvenNumbers() public view returns (uint) {
        uint count = 0;
        
        for(uint i = 0; i < numbers.length; i++) {
            if(isEvenNumber(numbers[i])) {
                count ++;
            }
        }
        return count;
    }

    function isEvenNumber(uint _number) public view returns(bool) {
        return (_number % 2 == 0 ? true : false);
    }
}
```
