Show the (decimal) value of a number of 1s appended with a 3, then squared: Difference between revisions

no edit summary
No edit summary
Line 358:
-> 123456832098769
</pre>
 
=={{header|Delphi}}==
{{works with|Delphi|6.0}}
{{libheader|SysUtils,StdCtrls}}
 
 
<syntaxhighlight lang="Delphi">
procedure OnesPlusThree(Memo: TMemo);
{Create pattern: 3, 13, 113, 1113, and square}
var NS: string;
var I: integer;
var NV: int64;
begin
{Start with 3 in number string}
NS:='3';
for I:=1 to 7 do
begin
{Convert to a number}
NV:=StrToInt(NS);
Memo.Lines.Add(Format('%2D - %10d^2 =%18.0n',[I,NV,NV*NV+0.0]));
{Add a "1" to the number string}
NS:='1'+NS;
end;
end;
 
</syntaxhighlight>
{{out}}
<pre>
1 - 3^2 = 9
2 - 13^2 = 169
3 - 113^2 = 12,769
4 - 1113^2 = 1,238,769
5 - 11113^2 = 123,498,769
6 - 111113^2 = 12,346,098,769
7 - 1111113^2 = 1,234,572,098,769
Elapsed Time: 8.668 ms.
 
</pre>
 
 
=={{header|F_Sharp|F#}}==
465

edits