Skip to content

Instantly share code, notes, and snippets.

@freeonterminate
Created August 28, 2013 07:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save freeonterminate/6363206 to your computer and use it in GitHub Desktop.
Save freeonterminate/6363206 to your computer and use it in GitHub Desktop.
Helper で FizzBuzz
program FizzBuzzHelper;
uses
System.SysUtils;
type
TFizzBuzzHelper = record helper for Integer
function ToFizzBuzz: String;
end;
function TFizzBuzzHelper.ToFizzBuzz: String;
begin
Result := '';
if (Self mod 3 = 0) then
Result := 'Fizz';
if (Self mod 5 = 0) then
Result := Result + 'Buzz';
if (Result = '') then
Result := IntToStr(Self);
end;
var
i: Integer;
begin
for i := 1 to 100 do
Writeln(i.ToFizzBuzz);
end.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment