Skip to main content

Dynamic loops

Dynamic loops are loops where the number of cycles is not necessarily known at compile time.

[[circuit]] int circuit_funct(int a, int b) {
for (int j=0; j < b; j++) {
a *= a;
}

return a
}

Dynamic loops must be replaced with static loops where the number of cycles is a literal or otherwise a value known at compile time.

tip

In addition to using literals, it is also possible to use the constexpr (C++) or the const (Rust) specifiers.

[[circuit]] int circuit_funct(int a) {
for (int j=0; j < 10; j++) {
a *= a;
}

return a
}