Skip to content

Instantly share code, notes, and snippets.

@GolezTrol
Created November 1, 2022 08:29
Show Gist options
  • Save GolezTrol/e0db1926fb8157ae73de86e134d87af7 to your computer and use it in GitHub Desktop.
Save GolezTrol/e0db1926fb8157ae73de86e134d87af7 to your computer and use it in GitHub Desktop.
An FizzBuzz implementation in Delphi
program FizzBuzz;
{$APPTYPE CONSOLE}
{$R *.res}
uses
System.SysUtils, System.Diagnostics;
begin
var Stopwatch := TStopwatch.StartNew;
var b := TStringBuilder.Create;
for var i := 1 to 100 do
begin
var s := '';
if i mod 3 = 0 then
s := 'Fizz';
if i mod 5 = 0 then
s := s + 'Buzz';
if s = '' then
b.AppendLine(i.ToString)
else
b.AppendLine(s);
end;
var s := b.ToString;
writeLn(s);
WriteLn((Stopwatch.ElapsedTicks / Stopwatch.Frequency * 1000000) .ToString + ' μs');
end.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment