<?php
function tekaTekiTeko( int $batas ) {
if ( $batas < 20 ) {
throw new InvalidArgumentException( "Parameter harus bernilai unsigned integer dan minimal 20." ) ;
}
for ( $i = 1 ; $i <= $batas ; $i ++ ) {
$output = "" ;
if ( $i % 2 === 0 ) {
$output .= "Teka" ;
}
if ( $i % 3 === 0 ) {
$output .= "Teki" ;
}
if ( $i % 5 === 0 ) {
$output .= "Teko" ;
}
echo ( $output === "" ? $i : $output ) . PHP_EOL;
}
}
try {
tekaTekiTeko( 30 ) ;
} catch ( Exception $e ) {
echo "Error: " . $e -> getMessage ( ) . PHP_EOL;
}
?>
PD9waHAKZnVuY3Rpb24gdGVrYVRla2lUZWtvKGludCAkYmF0YXMpIHsKICAgIGlmICgkYmF0YXMgPCAyMCkgewogICAgICAgIHRocm93IG5ldyBJbnZhbGlkQXJndW1lbnRFeGNlcHRpb24oIlBhcmFtZXRlciBoYXJ1cyBiZXJuaWxhaSB1bnNpZ25lZCBpbnRlZ2VyIGRhbiBtaW5pbWFsIDIwLiIpOwogICAgfQogICAgZm9yICgkaSA9IDE7ICRpIDw9ICRiYXRhczsgJGkrKykgewogICAgICAgICRvdXRwdXQgPSAiIjsKICAgICAgICBpZiAoJGkgJSAyID09PSAwKSB7CiAgICAgICAgICAgICRvdXRwdXQgLj0gIlRla2EiOwogICAgICAgIH0KICAgICAgICBpZiAoJGkgJSAzID09PSAwKSB7CiAgICAgICAgICAgICRvdXRwdXQgLj0gIlRla2kiOwogICAgICAgIH0KICAgICAgICBpZiAoJGkgJSA1ID09PSAwKSB7CiAgICAgICAgICAgICRvdXRwdXQgLj0gIlRla28iOwogICAgICAgIH0KICAgICAgICBlY2hvICgkb3V0cHV0ID09PSAiIiA/ICRpIDogJG91dHB1dCkgLiBQSFBfRU9MOwogICAgfQp9CnRyeSB7CiAgICB0ZWthVGVraVRla28oMzApOwp9IGNhdGNoIChFeGNlcHRpb24gJGUpIHsKICAgIGVjaG8gIkVycm9yOiAiIC4gJGUtPmdldE1lc3NhZ2UoKSAuIFBIUF9FT0w7Cn0KPz4K