Compile-time calculation: Difference between revisions

Content added Content deleted
m (added wording to highlight the ten factorial expression.)
(Added FreeBASIC)
Line 383: Line 383:
end program test
end program test
</lang>
</lang>

=={{header|FreeBASIC}}==
<lang freebasic>' FB 1.05.0 Win64

' Calculations can be done in a Const declaration at compile time
' provided only literals or other constant expressions are used
Const factorial As Integer = 2 * 3 * 4 * 5 * 6 * 7 * 8 * 9 * 10
Print factorial ' 3628800
Sleep</lang>

=={{header|Go}}==
=={{header|Go}}==
Constant expressions are evaluated at compile time. A constant expression though, is pretty simple and can't have much more than literals, operators, and a special thing called iota. There is no way to loop in a constant expression and so the expanded expression below is about the simplest way of completing this task.
Constant expressions are evaluated at compile time. A constant expression though, is pretty simple and can't have much more than literals, operators, and a special thing called iota. There is no way to loop in a constant expression and so the expanded expression below is about the simplest way of completing this task.