MyChat Scripts: function Sqr, calculating a square of a number
"For developers", "Server scripts", "Functions descriptions", "Mathematical", "Sqr".
Calculating a square of a number.
Syntax
function Sqr(x: extended): extended;
Parameters and return values
Parameter |
Type |
Value |
x |
extended |
an integer for calculating a second power of an integer. |
Function result
Real integer.
Пример
const
MAX_VALUE = 10;
var
i: integer;
s: string;
begin
for i := 1 to MAX_VALUE do begin
s := IntToStr(i);
mLogScript(IntToStr(Round(Sqr(i))), s + 'x' + s);
end;
end.
Script work result
[13:10:01] (Log "Sqr"): [1x1] 1
[13:10:01] (Log "Sqr"): [2x2] 4
[13:10:01] (Log "Sqr"): [3x3] 9
[13:10:01] (Log "Sqr"): [4x4] 16
[13:10:01] (Log "Sqr"): [5x5] 25
[13:10:01] (Log "Sqr"): [6x6] 36
[13:10:01] (Log "Sqr"): [7x7] 49
[13:10:01] (Log "Sqr"): [8x8] 64
[13:10:01] (Log "Sqr"): [9x9] 81
[13:10:01] (Log "Sqr"): [10x10] 100
[13:10:01] (Run "Sqr"): Script operation time: 3 ms
[13:10:01] (Run "Sqr"): Script done successfully.