Jump to content

Compile-time calculation: Difference between revisions

Added FreeBASIC
m (added wording to highlight the ten factorial expression.)
(Added FreeBASIC)
Line 383:
end program test
</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}}==
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.
9,490

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.