# 4.自然数自增

在本章节中，将编写一个创建actor并提供几个函数来增加一个计数器的程序，同时会讲解如何维护一个值。

本章节中，actor被命名为Counter。程序使用 currentValue值来包含一个代表counter当前值的自然数。这个程序会支持下面的函数调用

* increment函数调用会将当前的值加1（无返回值）
* get函数会调用查询并返回当前的值
* set函数会将当前的值更新为用户输入的值

本章节提供一个简单的示例，展示如何在部署的Canister中调用函数来增加一个计数器。通过多次调用函数来增加值，可以验证变量状态和变量在调用之间的持续性。


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://mixlabs.gitbook.io/dfinitytutorials/si-.-jiao-cheng/4.-zi-ran-shu-zi-zeng.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
