Created
November 1, 2022 08:29
-
-
Save GolezTrol/e0db1926fb8157ae73de86e134d87af7 to your computer and use it in GitHub Desktop.
An FizzBuzz implementation in Delphi
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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