Instruction
stringlengths
45
106
input_code
stringlengths
1
13.7k
output_code
stringlengths
1
13.7k
Generate an equivalent C# version of this OCaml code.
let format (n : Int) : Latin1 = if (n mod 3 = 0) || (n mod 5 = 0) then "FizzBuzz" else if (n mod 5 = 0) then "Buzz" else if (n mod 3 = 0) then "Fizz" else string_of (n);; let fizz (n : Int, size : Int) : _ = print (format (n) @ "\n"); if (n = size) then n = 0 else fizz(n...
class Program { public void FizzBuzzGo() { Boolean Fizz = false; Boolean Buzz = false; for (int count = 1; count <= 100; count ++) { Fizz = count % 3 == 0; Buzz = count % 5 == 0; if (Fizz && Buzz) { Console.WriteLine...
Write the same algorithm in Java as shown in this OCaml implementation.
let format (n : Int) : Latin1 = if (n mod 3 = 0) || (n mod 5 = 0) then "FizzBuzz" else if (n mod 5 = 0) then "Buzz" else if (n mod 3 = 0) then "Fizz" else string_of (n);; let fizz (n : Int, size : Int) : _ = print (format (n) @ "\n"); if (n = size) then n = 0 else fizz(n...
module FizzBuzz { void run() { @Inject Console console; for (Int x : 1..100) { console.print(switch (x % 3, x % 5) { case (0, 0): "FizzBuzz"; case (0, _): "Fizz"; case (_, 0): "Buzz"; ...
Port the following code from OCaml to Python with equivalent syntax and logic.
let format (n : Int) : Latin1 = if (n mod 3 = 0) || (n mod 5 = 0) then "FizzBuzz" else if (n mod 5 = 0) then "Buzz" else if (n mod 3 = 0) then "Fizz" else string_of (n);; let fizz (n : Int, size : Int) : _ = print (format (n) @ "\n"); if (n = size) then n = 0 else fizz(n...
for i in xrange(1, 101): if i % 15 == 0: print "FizzBuzz" elif i % 3 == 0: print "Fizz" elif i % 5 == 0: print "Buzz" else: print i
Ensure the translated VB code behaves exactly like the original OCaml snippet.
let format (n : Int) : Latin1 = if (n mod 3 = 0) || (n mod 5 = 0) then "FizzBuzz" else if (n mod 5 = 0) then "Buzz" else if (n mod 3 = 0) then "Fizz" else string_of (n);; let fizz (n : Int, size : Int) : _ = print (format (n) @ "\n"); if (n = size) then n = 0 else fizz(n...
Option Explicit Sub FizzBuzz() Dim Tb(1 To 100) As Variant Dim i As Integer For i = 1 To 100 If i Mod 15 = 0 Then Tb(i) = "FizzBuzz" ElseIf i Mod 5 = 0 Then Tb(i) = "Buzz" ElseIf i Mod 3 = 0 Then Tb(i) = "Fizz" Else Tb(i) = i ...
Can you help me rewrite this code in Go instead of OCaml, keeping it the same logically?
let format (n : Int) : Latin1 = if (n mod 3 = 0) || (n mod 5 = 0) then "FizzBuzz" else if (n mod 5 = 0) then "Buzz" else if (n mod 3 = 0) then "Fizz" else string_of (n);; let fizz (n : Int, size : Int) : _ = print (format (n) @ "\n"); if (n = size) then n = 0 else fizz(n...
package main import "fmt" func main() { for i := 1; i <= 100; i++ { switch { case i%15==0: fmt.Println("FizzBuzz") case i%3==0: fmt.Println("Fizz") case i%5==0: fmt.Println("Buzz") default: fmt.Println(i) } } }
Keep all operations the same but rewrite the snippet in C.
program fizzbuzz(output); var i: integer; begin for i := 1 to 100 do if i mod 15 = 0 then writeln('FizzBuzz') else if i mod 3 = 0 then writeln('Fizz') else if i mod 5 = 0 then writeln('Buzz') else writeln(i) end.
int i = 0 ; char B[88] ; while ( i++ < 100 ) !sprintf( B, "%s%s", i%3 ? "":"Fizz", i%5 ? "":"Buzz" ) ? sprintf( B, "%d", i ):0, printf( ", %s", B );
Ensure the translated C# code behaves exactly like the original Pascal snippet.
program fizzbuzz(output); var i: integer; begin for i := 1 to 100 do if i mod 15 = 0 then writeln('FizzBuzz') else if i mod 3 = 0 then writeln('Fizz') else if i mod 5 = 0 then writeln('Buzz') else writeln(i) end.
class Program { public void FizzBuzzGo() { Boolean Fizz = false; Boolean Buzz = false; for (int count = 1; count <= 100; count ++) { Fizz = count % 3 == 0; Buzz = count % 5 == 0; if (Fizz && Buzz) { Console.WriteLine...
Write the same algorithm in C++ as shown in this Pascal implementation.
program fizzbuzz(output); var i: integer; begin for i := 1 to 100 do if i mod 15 = 0 then writeln('FizzBuzz') else if i mod 3 = 0 then writeln('Fizz') else if i mod 5 = 0 then writeln('Buzz') else writeln(i) end.
#include <iostream> #include <chrono> int main() { int fizz = 0, buzz = 0, fizzbuzz = 0; bool isFizz = false; auto startTime = std::chrono::high_resolution_clock::now(); for (unsigned int i = 1; i <= 4000000000; i++) { isFizz = false; if (i % 3 == 0) { isFizz = true; fizz++; } if (i % 5 == 0) {...
Rewrite the snippet below in Java so it works the same as the original Pascal code.
program fizzbuzz(output); var i: integer; begin for i := 1 to 100 do if i mod 15 = 0 then writeln('FizzBuzz') else if i mod 3 = 0 then writeln('Fizz') else if i mod 5 = 0 then writeln('Buzz') else writeln(i) end.
module FizzBuzz { void run() { @Inject Console console; for (Int x : 1..100) { console.print(switch (x % 3, x % 5) { case (0, 0): "FizzBuzz"; case (0, _): "Fizz"; case (_, 0): "Buzz"; ...
Rewrite the snippet below in Python so it works the same as the original Pascal code.
program fizzbuzz(output); var i: integer; begin for i := 1 to 100 do if i mod 15 = 0 then writeln('FizzBuzz') else if i mod 3 = 0 then writeln('Fizz') else if i mod 5 = 0 then writeln('Buzz') else writeln(i) end.
for i in xrange(1, 101): if i % 15 == 0: print "FizzBuzz" elif i % 3 == 0: print "Fizz" elif i % 5 == 0: print "Buzz" else: print i
Please provide an equivalent version of this Pascal code in VB.
program fizzbuzz(output); var i: integer; begin for i := 1 to 100 do if i mod 15 = 0 then writeln('FizzBuzz') else if i mod 3 = 0 then writeln('Fizz') else if i mod 5 = 0 then writeln('Buzz') else writeln(i) end.
Option Explicit Sub FizzBuzz() Dim Tb(1 To 100) As Variant Dim i As Integer For i = 1 To 100 If i Mod 15 = 0 Then Tb(i) = "FizzBuzz" ElseIf i Mod 5 = 0 Then Tb(i) = "Buzz" ElseIf i Mod 3 = 0 Then Tb(i) = "Fizz" Else Tb(i) = i ...
Can you help me rewrite this code in Go instead of Pascal, keeping it the same logically?
program fizzbuzz(output); var i: integer; begin for i := 1 to 100 do if i mod 15 = 0 then writeln('FizzBuzz') else if i mod 3 = 0 then writeln('Fizz') else if i mod 5 = 0 then writeln('Buzz') else writeln(i) end.
package main import "fmt" func main() { for i := 1; i <= 100; i++ { switch { case i%15==0: fmt.Println("FizzBuzz") case i%3==0: fmt.Println("Fizz") case i%5==0: fmt.Println("Buzz") default: fmt.Println(i) } } }
Produce a functionally identical C code for the snippet given in Perl.
use strict; use warnings; use feature qw(say); for my $i (1..100) { say $i % 15 == 0 ? "FizzBuzz" : $i % 3 == 0 ? "Fizz" : $i % 5 == 0 ? "Buzz" : $i; }
int i = 0 ; char B[88] ; while ( i++ < 100 ) !sprintf( B, "%s%s", i%3 ? "":"Fizz", i%5 ? "":"Buzz" ) ? sprintf( B, "%d", i ):0, printf( ", %s", B );
Write the same algorithm in C# as shown in this Perl implementation.
use strict; use warnings; use feature qw(say); for my $i (1..100) { say $i % 15 == 0 ? "FizzBuzz" : $i % 3 == 0 ? "Fizz" : $i % 5 == 0 ? "Buzz" : $i; }
class Program { public void FizzBuzzGo() { Boolean Fizz = false; Boolean Buzz = false; for (int count = 1; count <= 100; count ++) { Fizz = count % 3 == 0; Buzz = count % 5 == 0; if (Fizz && Buzz) { Console.WriteLine...
Maintain the same structure and functionality when rewriting this code in C++.
use strict; use warnings; use feature qw(say); for my $i (1..100) { say $i % 15 == 0 ? "FizzBuzz" : $i % 3 == 0 ? "Fizz" : $i % 5 == 0 ? "Buzz" : $i; }
#include <iostream> #include <chrono> int main() { int fizz = 0, buzz = 0, fizzbuzz = 0; bool isFizz = false; auto startTime = std::chrono::high_resolution_clock::now(); for (unsigned int i = 1; i <= 4000000000; i++) { isFizz = false; if (i % 3 == 0) { isFizz = true; fizz++; } if (i % 5 == 0) {...
Rewrite this program in Java while keeping its functionality equivalent to the Perl version.
use strict; use warnings; use feature qw(say); for my $i (1..100) { say $i % 15 == 0 ? "FizzBuzz" : $i % 3 == 0 ? "Fizz" : $i % 5 == 0 ? "Buzz" : $i; }
module FizzBuzz { void run() { @Inject Console console; for (Int x : 1..100) { console.print(switch (x % 3, x % 5) { case (0, 0): "FizzBuzz"; case (0, _): "Fizz"; case (_, 0): "Buzz"; ...
Please provide an equivalent version of this Perl code in Python.
use strict; use warnings; use feature qw(say); for my $i (1..100) { say $i % 15 == 0 ? "FizzBuzz" : $i % 3 == 0 ? "Fizz" : $i % 5 == 0 ? "Buzz" : $i; }
for i in xrange(1, 101): if i % 15 == 0: print "FizzBuzz" elif i % 3 == 0: print "Fizz" elif i % 5 == 0: print "Buzz" else: print i
Convert this Perl snippet to VB and keep its semantics consistent.
use strict; use warnings; use feature qw(say); for my $i (1..100) { say $i % 15 == 0 ? "FizzBuzz" : $i % 3 == 0 ? "Fizz" : $i % 5 == 0 ? "Buzz" : $i; }
Option Explicit Sub FizzBuzz() Dim Tb(1 To 100) As Variant Dim i As Integer For i = 1 To 100 If i Mod 15 = 0 Then Tb(i) = "FizzBuzz" ElseIf i Mod 5 = 0 Then Tb(i) = "Buzz" ElseIf i Mod 3 = 0 Then Tb(i) = "Fizz" Else Tb(i) = i ...
Write the same code in Go as shown below in Perl.
use strict; use warnings; use feature qw(say); for my $i (1..100) { say $i % 15 == 0 ? "FizzBuzz" : $i % 3 == 0 ? "Fizz" : $i % 5 == 0 ? "Buzz" : $i; }
package main import "fmt" func main() { for i := 1; i <= 100; i++ { switch { case i%15==0: fmt.Println("FizzBuzz") case i%3==0: fmt.Println("Fizz") case i%5==0: fmt.Println("Buzz") default: fmt.Println(i) } } }
Generate an equivalent C version of this PowerShell code.
for ($i = 1; $i -le 100; $i++) { if ($i % 15 -eq 0) { "FizzBuzz" } elseif ($i % 5 -eq 0) { "Buzz" } elseif ($i % 3 -eq 0) { "Fizz" } else { $i } }
int i = 0 ; char B[88] ; while ( i++ < 100 ) !sprintf( B, "%s%s", i%3 ? "":"Fizz", i%5 ? "":"Buzz" ) ? sprintf( B, "%d", i ):0, printf( ", %s", B );
Maintain the same structure and functionality when rewriting this code in C#.
for ($i = 1; $i -le 100; $i++) { if ($i % 15 -eq 0) { "FizzBuzz" } elseif ($i % 5 -eq 0) { "Buzz" } elseif ($i % 3 -eq 0) { "Fizz" } else { $i } }
class Program { public void FizzBuzzGo() { Boolean Fizz = false; Boolean Buzz = false; for (int count = 1; count <= 100; count ++) { Fizz = count % 3 == 0; Buzz = count % 5 == 0; if (Fizz && Buzz) { Console.WriteLine...
Maintain the same structure and functionality when rewriting this code in C++.
for ($i = 1; $i -le 100; $i++) { if ($i % 15 -eq 0) { "FizzBuzz" } elseif ($i % 5 -eq 0) { "Buzz" } elseif ($i % 3 -eq 0) { "Fizz" } else { $i } }
#include <iostream> #include <chrono> int main() { int fizz = 0, buzz = 0, fizzbuzz = 0; bool isFizz = false; auto startTime = std::chrono::high_resolution_clock::now(); for (unsigned int i = 1; i <= 4000000000; i++) { isFizz = false; if (i % 3 == 0) { isFizz = true; fizz++; } if (i % 5 == 0) {...
Port the provided PowerShell code into Java while preserving the original functionality.
for ($i = 1; $i -le 100; $i++) { if ($i % 15 -eq 0) { "FizzBuzz" } elseif ($i % 5 -eq 0) { "Buzz" } elseif ($i % 3 -eq 0) { "Fizz" } else { $i } }
module FizzBuzz { void run() { @Inject Console console; for (Int x : 1..100) { console.print(switch (x % 3, x % 5) { case (0, 0): "FizzBuzz"; case (0, _): "Fizz"; case (_, 0): "Buzz"; ...
Convert the following code from PowerShell to Python, ensuring the logic remains intact.
for ($i = 1; $i -le 100; $i++) { if ($i % 15 -eq 0) { "FizzBuzz" } elseif ($i % 5 -eq 0) { "Buzz" } elseif ($i % 3 -eq 0) { "Fizz" } else { $i } }
for i in xrange(1, 101): if i % 15 == 0: print "FizzBuzz" elif i % 3 == 0: print "Fizz" elif i % 5 == 0: print "Buzz" else: print i
Port the following code from PowerShell to VB with equivalent syntax and logic.
for ($i = 1; $i -le 100; $i++) { if ($i % 15 -eq 0) { "FizzBuzz" } elseif ($i % 5 -eq 0) { "Buzz" } elseif ($i % 3 -eq 0) { "Fizz" } else { $i } }
Option Explicit Sub FizzBuzz() Dim Tb(1 To 100) As Variant Dim i As Integer For i = 1 To 100 If i Mod 15 = 0 Then Tb(i) = "FizzBuzz" ElseIf i Mod 5 = 0 Then Tb(i) = "Buzz" ElseIf i Mod 3 = 0 Then Tb(i) = "Fizz" Else Tb(i) = i ...
Write a version of this PowerShell function in Go with identical behavior.
for ($i = 1; $i -le 100; $i++) { if ($i % 15 -eq 0) { "FizzBuzz" } elseif ($i % 5 -eq 0) { "Buzz" } elseif ($i % 3 -eq 0) { "Fizz" } else { $i } }
package main import "fmt" func main() { for i := 1; i <= 100; i++ { switch { case i%15==0: fmt.Println("FizzBuzz") case i%3==0: fmt.Println("Fizz") case i%5==0: fmt.Println("Buzz") default: fmt.Println(i) } } }
Transform the following Racket implementation into C, maintaining the same output and logic.
#lang racket (for ([n (in-range 1 101)]) (displayln (match (gcd n 15) [15 "fizzbuzz"] [3 "fizz"] [5 "buzz"] [_ n])))
int i = 0 ; char B[88] ; while ( i++ < 100 ) !sprintf( B, "%s%s", i%3 ? "":"Fizz", i%5 ? "":"Buzz" ) ? sprintf( B, "%d", i ):0, printf( ", %s", B );
Translate the given Racket code snippet into C# without altering its behavior.
#lang racket (for ([n (in-range 1 101)]) (displayln (match (gcd n 15) [15 "fizzbuzz"] [3 "fizz"] [5 "buzz"] [_ n])))
class Program { public void FizzBuzzGo() { Boolean Fizz = false; Boolean Buzz = false; for (int count = 1; count <= 100; count ++) { Fizz = count % 3 == 0; Buzz = count % 5 == 0; if (Fizz && Buzz) { Console.WriteLine...
Convert this Racket snippet to C++ and keep its semantics consistent.
#lang racket (for ([n (in-range 1 101)]) (displayln (match (gcd n 15) [15 "fizzbuzz"] [3 "fizz"] [5 "buzz"] [_ n])))
#include <iostream> #include <chrono> int main() { int fizz = 0, buzz = 0, fizzbuzz = 0; bool isFizz = false; auto startTime = std::chrono::high_resolution_clock::now(); for (unsigned int i = 1; i <= 4000000000; i++) { isFizz = false; if (i % 3 == 0) { isFizz = true; fizz++; } if (i % 5 == 0) {...
Generate an equivalent Java version of this Racket code.
#lang racket (for ([n (in-range 1 101)]) (displayln (match (gcd n 15) [15 "fizzbuzz"] [3 "fizz"] [5 "buzz"] [_ n])))
module FizzBuzz { void run() { @Inject Console console; for (Int x : 1..100) { console.print(switch (x % 3, x % 5) { case (0, 0): "FizzBuzz"; case (0, _): "Fizz"; case (_, 0): "Buzz"; ...
Change the programming language of this snippet from Racket to Python without modifying what it does.
#lang racket (for ([n (in-range 1 101)]) (displayln (match (gcd n 15) [15 "fizzbuzz"] [3 "fizz"] [5 "buzz"] [_ n])))
for i in xrange(1, 101): if i % 15 == 0: print "FizzBuzz" elif i % 3 == 0: print "Fizz" elif i % 5 == 0: print "Buzz" else: print i
Please provide an equivalent version of this Racket code in VB.
#lang racket (for ([n (in-range 1 101)]) (displayln (match (gcd n 15) [15 "fizzbuzz"] [3 "fizz"] [5 "buzz"] [_ n])))
Option Explicit Sub FizzBuzz() Dim Tb(1 To 100) As Variant Dim i As Integer For i = 1 To 100 If i Mod 15 = 0 Then Tb(i) = "FizzBuzz" ElseIf i Mod 5 = 0 Then Tb(i) = "Buzz" ElseIf i Mod 3 = 0 Then Tb(i) = "Fizz" Else Tb(i) = i ...
Ensure the translated Go code behaves exactly like the original Racket snippet.
#lang racket (for ([n (in-range 1 101)]) (displayln (match (gcd n 15) [15 "fizzbuzz"] [3 "fizz"] [5 "buzz"] [_ n])))
package main import "fmt" func main() { for i := 1; i <= 100; i++ { switch { case i%15==0: fmt.Println("FizzBuzz") case i%3==0: fmt.Println("Fizz") case i%5==0: fmt.Println("Buzz") default: fmt.Println(i) } } }
Port the following code from COBOL to C with equivalent syntax and logic.
* FIZZBUZZ.COB * cobc -x -g FIZZBUZZ.COB * IDENTIFICATION DIVISION. PROGRAM-ID. fizzbuzz. DATA DIVISION. WORKING-STORAGE SECTION. 01 CNT PIC 9(03) VALUE 1. 01 REM PIC 9(03) VALUE 0. 01 QUOTIENT PIC 9(03)...
int i = 0 ; char B[88] ; while ( i++ < 100 ) !sprintf( B, "%s%s", i%3 ? "":"Fizz", i%5 ? "":"Buzz" ) ? sprintf( B, "%d", i ):0, printf( ", %s", B );
Change the programming language of this snippet from COBOL to C# without modifying what it does.
* FIZZBUZZ.COB * cobc -x -g FIZZBUZZ.COB * IDENTIFICATION DIVISION. PROGRAM-ID. fizzbuzz. DATA DIVISION. WORKING-STORAGE SECTION. 01 CNT PIC 9(03) VALUE 1. 01 REM PIC 9(03) VALUE 0. 01 QUOTIENT PIC 9(03)...
class Program { public void FizzBuzzGo() { Boolean Fizz = false; Boolean Buzz = false; for (int count = 1; count <= 100; count ++) { Fizz = count % 3 == 0; Buzz = count % 5 == 0; if (Fizz && Buzz) { Console.WriteLine...
Please provide an equivalent version of this COBOL code in C++.
* FIZZBUZZ.COB * cobc -x -g FIZZBUZZ.COB * IDENTIFICATION DIVISION. PROGRAM-ID. fizzbuzz. DATA DIVISION. WORKING-STORAGE SECTION. 01 CNT PIC 9(03) VALUE 1. 01 REM PIC 9(03) VALUE 0. 01 QUOTIENT PIC 9(03)...
#include <iostream> #include <chrono> int main() { int fizz = 0, buzz = 0, fizzbuzz = 0; bool isFizz = false; auto startTime = std::chrono::high_resolution_clock::now(); for (unsigned int i = 1; i <= 4000000000; i++) { isFizz = false; if (i % 3 == 0) { isFizz = true; fizz++; } if (i % 5 == 0) {...
Rewrite this program in Java while keeping its functionality equivalent to the COBOL version.
* FIZZBUZZ.COB * cobc -x -g FIZZBUZZ.COB * IDENTIFICATION DIVISION. PROGRAM-ID. fizzbuzz. DATA DIVISION. WORKING-STORAGE SECTION. 01 CNT PIC 9(03) VALUE 1. 01 REM PIC 9(03) VALUE 0. 01 QUOTIENT PIC 9(03)...
module FizzBuzz { void run() { @Inject Console console; for (Int x : 1..100) { console.print(switch (x % 3, x % 5) { case (0, 0): "FizzBuzz"; case (0, _): "Fizz"; case (_, 0): "Buzz"; ...
Port the provided COBOL code into Python while preserving the original functionality.
* FIZZBUZZ.COB * cobc -x -g FIZZBUZZ.COB * IDENTIFICATION DIVISION. PROGRAM-ID. fizzbuzz. DATA DIVISION. WORKING-STORAGE SECTION. 01 CNT PIC 9(03) VALUE 1. 01 REM PIC 9(03) VALUE 0. 01 QUOTIENT PIC 9(03)...
for i in xrange(1, 101): if i % 15 == 0: print "FizzBuzz" elif i % 3 == 0: print "Fizz" elif i % 5 == 0: print "Buzz" else: print i
Convert the following code from COBOL to VB, ensuring the logic remains intact.
* FIZZBUZZ.COB * cobc -x -g FIZZBUZZ.COB * IDENTIFICATION DIVISION. PROGRAM-ID. fizzbuzz. DATA DIVISION. WORKING-STORAGE SECTION. 01 CNT PIC 9(03) VALUE 1. 01 REM PIC 9(03) VALUE 0. 01 QUOTIENT PIC 9(03)...
Option Explicit Sub FizzBuzz() Dim Tb(1 To 100) As Variant Dim i As Integer For i = 1 To 100 If i Mod 15 = 0 Then Tb(i) = "FizzBuzz" ElseIf i Mod 5 = 0 Then Tb(i) = "Buzz" ElseIf i Mod 3 = 0 Then Tb(i) = "Fizz" Else Tb(i) = i ...
Produce a language-to-language conversion: from COBOL to Go, same semantics.
* FIZZBUZZ.COB * cobc -x -g FIZZBUZZ.COB * IDENTIFICATION DIVISION. PROGRAM-ID. fizzbuzz. DATA DIVISION. WORKING-STORAGE SECTION. 01 CNT PIC 9(03) VALUE 1. 01 REM PIC 9(03) VALUE 0. 01 QUOTIENT PIC 9(03)...
package main import "fmt" func main() { for i := 1; i <= 100; i++ { switch { case i%15==0: fmt.Println("FizzBuzz") case i%3==0: fmt.Println("Fizz") case i%5==0: fmt.Println("Buzz") default: fmt.Println(i) } } }
Rewrite this program in C while keeping its functionality equivalent to the REXX version.
loop j=1 for 100 select when j//15==0 then say 'FizzBuzz' when j//5==0 then say 'Buzz' when j//3==0 then say 'Fizz' otherwise say j.right(4) end end
int i = 0 ; char B[88] ; while ( i++ < 100 ) !sprintf( B, "%s%s", i%3 ? "":"Fizz", i%5 ? "":"Buzz" ) ? sprintf( B, "%d", i ):0, printf( ", %s", B );
Generate a C# translation of this REXX snippet without changing its computational steps.
loop j=1 for 100 select when j//15==0 then say 'FizzBuzz' when j//5==0 then say 'Buzz' when j//3==0 then say 'Fizz' otherwise say j.right(4) end end
class Program { public void FizzBuzzGo() { Boolean Fizz = false; Boolean Buzz = false; for (int count = 1; count <= 100; count ++) { Fizz = count % 3 == 0; Buzz = count % 5 == 0; if (Fizz && Buzz) { Console.WriteLine...
Convert this REXX snippet to C++ and keep its semantics consistent.
loop j=1 for 100 select when j//15==0 then say 'FizzBuzz' when j//5==0 then say 'Buzz' when j//3==0 then say 'Fizz' otherwise say j.right(4) end end
#include <iostream> #include <chrono> int main() { int fizz = 0, buzz = 0, fizzbuzz = 0; bool isFizz = false; auto startTime = std::chrono::high_resolution_clock::now(); for (unsigned int i = 1; i <= 4000000000; i++) { isFizz = false; if (i % 3 == 0) { isFizz = true; fizz++; } if (i % 5 == 0) {...
Generate a Java translation of this REXX snippet without changing its computational steps.
loop j=1 for 100 select when j//15==0 then say 'FizzBuzz' when j//5==0 then say 'Buzz' when j//3==0 then say 'Fizz' otherwise say j.right(4) end end
module FizzBuzz { void run() { @Inject Console console; for (Int x : 1..100) { console.print(switch (x % 3, x % 5) { case (0, 0): "FizzBuzz"; case (0, _): "Fizz"; case (_, 0): "Buzz"; ...
Convert the following code from REXX to Python, ensuring the logic remains intact.
loop j=1 for 100 select when j//15==0 then say 'FizzBuzz' when j//5==0 then say 'Buzz' when j//3==0 then say 'Fizz' otherwise say j.right(4) end end
for i in xrange(1, 101): if i % 15 == 0: print "FizzBuzz" elif i % 3 == 0: print "Fizz" elif i % 5 == 0: print "Buzz" else: print i
Generate a VB translation of this REXX snippet without changing its computational steps.
loop j=1 for 100 select when j//15==0 then say 'FizzBuzz' when j//5==0 then say 'Buzz' when j//3==0 then say 'Fizz' otherwise say j.right(4) end end
Option Explicit Sub FizzBuzz() Dim Tb(1 To 100) As Variant Dim i As Integer For i = 1 To 100 If i Mod 15 = 0 Then Tb(i) = "FizzBuzz" ElseIf i Mod 5 = 0 Then Tb(i) = "Buzz" ElseIf i Mod 3 = 0 Then Tb(i) = "Fizz" Else Tb(i) = i ...
Change the following REXX code into Go without altering its purpose.
loop j=1 for 100 select when j//15==0 then say 'FizzBuzz' when j//5==0 then say 'Buzz' when j//3==0 then say 'Fizz' otherwise say j.right(4) end end
package main import "fmt" func main() { for i := 1; i <= 100; i++ { switch { case i%15==0: fmt.Println("FizzBuzz") case i%3==0: fmt.Println("Fizz") case i%5==0: fmt.Println("Buzz") default: fmt.Println(i) } } }
Convert the following code from Ruby to C, ensuring the logic remains intact.
1.upto(100) do |v| p fizz_buzz(v) end def fizz_buzz(value) word = "" word += "fizz" if value % 3 == 0 word += "buzz" if value % 5 == 0 word += value.to_s if word.empty? word end
int i = 0 ; char B[88] ; while ( i++ < 100 ) !sprintf( B, "%s%s", i%3 ? "":"Fizz", i%5 ? "":"Buzz" ) ? sprintf( B, "%d", i ):0, printf( ", %s", B );
Translate this program into C# but keep the logic exactly as in Ruby.
1.upto(100) do |v| p fizz_buzz(v) end def fizz_buzz(value) word = "" word += "fizz" if value % 3 == 0 word += "buzz" if value % 5 == 0 word += value.to_s if word.empty? word end
class Program { public void FizzBuzzGo() { Boolean Fizz = false; Boolean Buzz = false; for (int count = 1; count <= 100; count ++) { Fizz = count % 3 == 0; Buzz = count % 5 == 0; if (Fizz && Buzz) { Console.WriteLine...
Change the programming language of this snippet from Ruby to C++ without modifying what it does.
1.upto(100) do |v| p fizz_buzz(v) end def fizz_buzz(value) word = "" word += "fizz" if value % 3 == 0 word += "buzz" if value % 5 == 0 word += value.to_s if word.empty? word end
#include <iostream> #include <chrono> int main() { int fizz = 0, buzz = 0, fizzbuzz = 0; bool isFizz = false; auto startTime = std::chrono::high_resolution_clock::now(); for (unsigned int i = 1; i <= 4000000000; i++) { isFizz = false; if (i % 3 == 0) { isFizz = true; fizz++; } if (i % 5 == 0) {...
Convert the following code from Ruby to Java, ensuring the logic remains intact.
1.upto(100) do |v| p fizz_buzz(v) end def fizz_buzz(value) word = "" word += "fizz" if value % 3 == 0 word += "buzz" if value % 5 == 0 word += value.to_s if word.empty? word end
module FizzBuzz { void run() { @Inject Console console; for (Int x : 1..100) { console.print(switch (x % 3, x % 5) { case (0, 0): "FizzBuzz"; case (0, _): "Fizz"; case (_, 0): "Buzz"; ...
Please provide an equivalent version of this Ruby code in Python.
1.upto(100) do |v| p fizz_buzz(v) end def fizz_buzz(value) word = "" word += "fizz" if value % 3 == 0 word += "buzz" if value % 5 == 0 word += value.to_s if word.empty? word end
for i in xrange(1, 101): if i % 15 == 0: print "FizzBuzz" elif i % 3 == 0: print "Fizz" elif i % 5 == 0: print "Buzz" else: print i
Convert this Ruby snippet to VB and keep its semantics consistent.
1.upto(100) do |v| p fizz_buzz(v) end def fizz_buzz(value) word = "" word += "fizz" if value % 3 == 0 word += "buzz" if value % 5 == 0 word += value.to_s if word.empty? word end
Option Explicit Sub FizzBuzz() Dim Tb(1 To 100) As Variant Dim i As Integer For i = 1 To 100 If i Mod 15 = 0 Then Tb(i) = "FizzBuzz" ElseIf i Mod 5 = 0 Then Tb(i) = "Buzz" ElseIf i Mod 3 = 0 Then Tb(i) = "Fizz" Else Tb(i) = i ...
Maintain the same structure and functionality when rewriting this code in Go.
1.upto(100) do |v| p fizz_buzz(v) end def fizz_buzz(value) word = "" word += "fizz" if value % 3 == 0 word += "buzz" if value % 5 == 0 word += value.to_s if word.empty? word end
package main import "fmt" func main() { for i := 1; i <= 100; i++ { switch { case i%15==0: fmt.Println("FizzBuzz") case i%3==0: fmt.Println("Fizz") case i%5==0: fmt.Println("Buzz") default: fmt.Println(i) } } }
Convert the following code from Scala to C, ensuring the logic remains intact.
fun fizzBuzz() { for (number in 1..100) { println( when { number % 15 == 0 -> "FizzBuzz" number % 3 == 0 -> "Fizz" number % 5 == 0 -> "Buzz" else -> number } ) } }
int i = 0 ; char B[88] ; while ( i++ < 100 ) !sprintf( B, "%s%s", i%3 ? "":"Fizz", i%5 ? "":"Buzz" ) ? sprintf( B, "%d", i ):0, printf( ", %s", B );
Translate this program into C# but keep the logic exactly as in Scala.
fun fizzBuzz() { for (number in 1..100) { println( when { number % 15 == 0 -> "FizzBuzz" number % 3 == 0 -> "Fizz" number % 5 == 0 -> "Buzz" else -> number } ) } }
class Program { public void FizzBuzzGo() { Boolean Fizz = false; Boolean Buzz = false; for (int count = 1; count <= 100; count ++) { Fizz = count % 3 == 0; Buzz = count % 5 == 0; if (Fizz && Buzz) { Console.WriteLine...
Convert the following code from Scala to C++, ensuring the logic remains intact.
fun fizzBuzz() { for (number in 1..100) { println( when { number % 15 == 0 -> "FizzBuzz" number % 3 == 0 -> "Fizz" number % 5 == 0 -> "Buzz" else -> number } ) } }
#include <iostream> #include <chrono> int main() { int fizz = 0, buzz = 0, fizzbuzz = 0; bool isFizz = false; auto startTime = std::chrono::high_resolution_clock::now(); for (unsigned int i = 1; i <= 4000000000; i++) { isFizz = false; if (i % 3 == 0) { isFizz = true; fizz++; } if (i % 5 == 0) {...
Change the programming language of this snippet from Scala to Java without modifying what it does.
fun fizzBuzz() { for (number in 1..100) { println( when { number % 15 == 0 -> "FizzBuzz" number % 3 == 0 -> "Fizz" number % 5 == 0 -> "Buzz" else -> number } ) } }
module FizzBuzz { void run() { @Inject Console console; for (Int x : 1..100) { console.print(switch (x % 3, x % 5) { case (0, 0): "FizzBuzz"; case (0, _): "Fizz"; case (_, 0): "Buzz"; ...
Produce a functionally identical Python code for the snippet given in Scala.
fun fizzBuzz() { for (number in 1..100) { println( when { number % 15 == 0 -> "FizzBuzz" number % 3 == 0 -> "Fizz" number % 5 == 0 -> "Buzz" else -> number } ) } }
for i in xrange(1, 101): if i % 15 == 0: print "FizzBuzz" elif i % 3 == 0: print "Fizz" elif i % 5 == 0: print "Buzz" else: print i
Keep all operations the same but rewrite the snippet in VB.
fun fizzBuzz() { for (number in 1..100) { println( when { number % 15 == 0 -> "FizzBuzz" number % 3 == 0 -> "Fizz" number % 5 == 0 -> "Buzz" else -> number } ) } }
Option Explicit Sub FizzBuzz() Dim Tb(1 To 100) As Variant Dim i As Integer For i = 1 To 100 If i Mod 15 = 0 Then Tb(i) = "FizzBuzz" ElseIf i Mod 5 = 0 Then Tb(i) = "Buzz" ElseIf i Mod 3 = 0 Then Tb(i) = "Fizz" Else Tb(i) = i ...
Convert the following code from Scala to Go, ensuring the logic remains intact.
fun fizzBuzz() { for (number in 1..100) { println( when { number % 15 == 0 -> "FizzBuzz" number % 3 == 0 -> "Fizz" number % 5 == 0 -> "Buzz" else -> number } ) } }
package main import "fmt" func main() { for i := 1; i <= 100; i++ { switch { case i%15==0: fmt.Println("FizzBuzz") case i%3==0: fmt.Println("Fizz") case i%5==0: fmt.Println("Buzz") default: fmt.Println(i) } } }
Preserve the algorithm and functionality while converting the code from Swift to C.
for i in 1...100 { switch (i % 3, i % 5) { case (0, 0): print("FizzBuzz") case (0, _): print("Fizz") case (_, 0): print("Buzz") default: print(i) } }
int i = 0 ; char B[88] ; while ( i++ < 100 ) !sprintf( B, "%s%s", i%3 ? "":"Fizz", i%5 ? "":"Buzz" ) ? sprintf( B, "%d", i ):0, printf( ", %s", B );
Change the programming language of this snippet from Swift to C# without modifying what it does.
for i in 1...100 { switch (i % 3, i % 5) { case (0, 0): print("FizzBuzz") case (0, _): print("Fizz") case (_, 0): print("Buzz") default: print(i) } }
class Program { public void FizzBuzzGo() { Boolean Fizz = false; Boolean Buzz = false; for (int count = 1; count <= 100; count ++) { Fizz = count % 3 == 0; Buzz = count % 5 == 0; if (Fizz && Buzz) { Console.WriteLine...
Port the provided Swift code into C++ while preserving the original functionality.
for i in 1...100 { switch (i % 3, i % 5) { case (0, 0): print("FizzBuzz") case (0, _): print("Fizz") case (_, 0): print("Buzz") default: print(i) } }
#include <iostream> #include <chrono> int main() { int fizz = 0, buzz = 0, fizzbuzz = 0; bool isFizz = false; auto startTime = std::chrono::high_resolution_clock::now(); for (unsigned int i = 1; i <= 4000000000; i++) { isFizz = false; if (i % 3 == 0) { isFizz = true; fizz++; } if (i % 5 == 0) {...
Write a version of this Swift function in Java with identical behavior.
for i in 1...100 { switch (i % 3, i % 5) { case (0, 0): print("FizzBuzz") case (0, _): print("Fizz") case (_, 0): print("Buzz") default: print(i) } }
module FizzBuzz { void run() { @Inject Console console; for (Int x : 1..100) { console.print(switch (x % 3, x % 5) { case (0, 0): "FizzBuzz"; case (0, _): "Fizz"; case (_, 0): "Buzz"; ...
Change the following Swift code into Python without altering its purpose.
for i in 1...100 { switch (i % 3, i % 5) { case (0, 0): print("FizzBuzz") case (0, _): print("Fizz") case (_, 0): print("Buzz") default: print(i) } }
for i in xrange(1, 101): if i % 15 == 0: print "FizzBuzz" elif i % 3 == 0: print "Fizz" elif i % 5 == 0: print "Buzz" else: print i
Generate a Go translation of this Swift snippet without changing its computational steps.
for i in 1...100 { switch (i % 3, i % 5) { case (0, 0): print("FizzBuzz") case (0, _): print("Fizz") case (_, 0): print("Buzz") default: print(i) } }
package main import "fmt" func main() { for i := 1; i <= 100; i++ { switch { case i%15==0: fmt.Println("FizzBuzz") case i%3==0: fmt.Println("Fizz") case i%5==0: fmt.Println("Buzz") default: fmt.Println(i) } } }
Port the following code from Tcl to C with equivalent syntax and logic.
for {set i 1} {$i <= 100} {inc i} { set show "" if {[expr $i % 3 == 0]} {set show "Fizz"} if {[expr $i % 5 == 0]} {set show $show"Buzz"} if {[expr [length $show] == 0]} {set show $i} print $show }
int i = 0 ; char B[88] ; while ( i++ < 100 ) !sprintf( B, "%s%s", i%3 ? "":"Fizz", i%5 ? "":"Buzz" ) ? sprintf( B, "%d", i ):0, printf( ", %s", B );
Change the following Tcl code into C# without altering its purpose.
for {set i 1} {$i <= 100} {inc i} { set show "" if {[expr $i % 3 == 0]} {set show "Fizz"} if {[expr $i % 5 == 0]} {set show $show"Buzz"} if {[expr [length $show] == 0]} {set show $i} print $show }
class Program { public void FizzBuzzGo() { Boolean Fizz = false; Boolean Buzz = false; for (int count = 1; count <= 100; count ++) { Fizz = count % 3 == 0; Buzz = count % 5 == 0; if (Fizz && Buzz) { Console.WriteLine...
Rewrite the snippet below in C++ so it works the same as the original Tcl code.
for {set i 1} {$i <= 100} {inc i} { set show "" if {[expr $i % 3 == 0]} {set show "Fizz"} if {[expr $i % 5 == 0]} {set show $show"Buzz"} if {[expr [length $show] == 0]} {set show $i} print $show }
#include <iostream> #include <chrono> int main() { int fizz = 0, buzz = 0, fizzbuzz = 0; bool isFizz = false; auto startTime = std::chrono::high_resolution_clock::now(); for (unsigned int i = 1; i <= 4000000000; i++) { isFizz = false; if (i % 3 == 0) { isFizz = true; fizz++; } if (i % 5 == 0) {...
Change the programming language of this snippet from Tcl to Java without modifying what it does.
for {set i 1} {$i <= 100} {inc i} { set show "" if {[expr $i % 3 == 0]} {set show "Fizz"} if {[expr $i % 5 == 0]} {set show $show"Buzz"} if {[expr [length $show] == 0]} {set show $i} print $show }
module FizzBuzz { void run() { @Inject Console console; for (Int x : 1..100) { console.print(switch (x % 3, x % 5) { case (0, 0): "FizzBuzz"; case (0, _): "Fizz"; case (_, 0): "Buzz"; ...
Please provide an equivalent version of this Tcl code in Python.
for {set i 1} {$i <= 100} {inc i} { set show "" if {[expr $i % 3 == 0]} {set show "Fizz"} if {[expr $i % 5 == 0]} {set show $show"Buzz"} if {[expr [length $show] == 0]} {set show $i} print $show }
for i in xrange(1, 101): if i % 15 == 0: print "FizzBuzz" elif i % 3 == 0: print "Fizz" elif i % 5 == 0: print "Buzz" else: print i
Change the following Tcl code into VB without altering its purpose.
for {set i 1} {$i <= 100} {inc i} { set show "" if {[expr $i % 3 == 0]} {set show "Fizz"} if {[expr $i % 5 == 0]} {set show $show"Buzz"} if {[expr [length $show] == 0]} {set show $i} print $show }
Option Explicit Sub FizzBuzz() Dim Tb(1 To 100) As Variant Dim i As Integer For i = 1 To 100 If i Mod 15 = 0 Then Tb(i) = "FizzBuzz" ElseIf i Mod 5 = 0 Then Tb(i) = "Buzz" ElseIf i Mod 3 = 0 Then Tb(i) = "Fizz" Else Tb(i) = i ...
Convert the following code from Tcl to Go, ensuring the logic remains intact.
for {set i 1} {$i <= 100} {inc i} { set show "" if {[expr $i % 3 == 0]} {set show "Fizz"} if {[expr $i % 5 == 0]} {set show $show"Buzz"} if {[expr [length $show] == 0]} {set show $i} print $show }
package main import "fmt" func main() { for i := 1; i <= 100; i++ { switch { case i%15==0: fmt.Println("FizzBuzz") case i%3==0: fmt.Println("Fizz") case i%5==0: fmt.Println("Buzz") default: fmt.Println(i) } } }
Convert this Rust snippet to PHP and keep its semantics consistent.
fn main() { for i in 1..=100 { match (i % 3, i % 5) { (0, 0) => println!("fizzbuzz"), (0, _) => println!("fizz"), (_, 0) => println!("buzz"), (_, _) => println!("{}", i), } } }
<?php for ($i = 1; $i <= 100; $i++) { if (!($i % 15)) echo "FizzBuzz\n"; else if (!($i % 3)) echo "Fizz\n"; else if (!($i % 5)) echo "Buzz\n"; else echo "$i\n"; } ?>
Translate this program into PHP but keep the logic exactly as in Ada.
with Ada.Text_IO; use Ada.Text_IO; procedure Fizzbuzz is begin for I in 1..100 loop if I mod 15 = 0 then Put_Line("FizzBuzz"); elsif I mod 5 = 0 then Put_Line("Buzz"); elsif I mod 3 = 0 then Put_Line("Fizz"); else Put_Line(Integer'Image(I)); end if;...
<?php for ($i = 1; $i <= 100; $i++) { if (!($i % 15)) echo "FizzBuzz\n"; else if (!($i % 3)) echo "Fizz\n"; else if (!($i % 5)) echo "Buzz\n"; else echo "$i\n"; } ?>
Port the following code from Arturo to PHP with equivalent syntax and logic.
loop 1..100 [x][ case [] when? [0=x%15] -> print "FizzBuzz" when? [0=x%3] -> print "Fizz" when? [0=x%5] -> print "Buzz" else -> print x ]
<?php for ($i = 1; $i <= 100; $i++) { if (!($i % 15)) echo "FizzBuzz\n"; else if (!($i % 3)) echo "Fizz\n"; else if (!($i % 5)) echo "Buzz\n"; else echo "$i\n"; } ?>
Port the following code from AutoHotKey to PHP with equivalent syntax and logic.
Loop, 100 { If (Mod(A_Index, 15) = 0) output .= "FizzBuzz`n" Else If (Mod(A_Index, 3) = 0) output .= "Fizz`n" Else If (Mod(A_Index, 5) = 0) output .= "Buzz`n" Else output .= A_Index "`n" } FileDelete, output.txt FileAppend, %output%, output.txt Run, cmd /k type output.txt
<?php for ($i = 1; $i <= 100; $i++) { if (!($i % 15)) echo "FizzBuzz\n"; else if (!($i % 3)) echo "Fizz\n"; else if (!($i % 5)) echo "Buzz\n"; else echo "$i\n"; } ?>
Generate an equivalent PHP version of this Clojure code.
(doseq [x (range 1 101)] (println x (str (when (zero? (mod x 3)) "fizz") (when (zero? (mod x 5)) "buzz"))))
<?php for ($i = 1; $i <= 100; $i++) { if (!($i % 15)) echo "FizzBuzz\n"; else if (!($i % 3)) echo "Fizz\n"; else if (!($i % 5)) echo "Buzz\n"; else echo "$i\n"; } ?>
Ensure the translated PHP code behaves exactly like the original Common_Lisp snippet.
(defun fizzbuzz-r (i) (declare (xargs :measure (nfix (- 100 i)))) (prog2$ (cond ((= (mod i 15) 0) (cw "FizzBuzz~%")) ((= (mod i 5) 0) (cw "Buzz~%")) ((= (mod i 3) 0) (cw "Fizz~%")) (t (cw "~x0~%" i))) (if (zp (- 100 i)) nil (fizzbuzz-r (1+ i))))) (defun fizzb...
<?php for ($i = 1; $i <= 100; $i++) { if (!($i % 15)) echo "FizzBuzz\n"; else if (!($i % 3)) echo "Fizz\n"; else if (!($i % 5)) echo "Buzz\n"; else echo "$i\n"; } ?>
Ensure the translated PHP code behaves exactly like the original D snippet.
import std.stdio, std.algorithm, std.conv; void fizzBuzz(in uint n) { foreach (immutable i; 1 .. n + 1) if (!(i % 15)) "FizzBuzz".writeln; else if (!(i % 3)) "Fizz".writeln; else if (!(i % 5)) "Buzz".writeln; else i.writeln; } void ...
<?php for ($i = 1; $i <= 100; $i++) { if (!($i % 15)) echo "FizzBuzz\n"; else if (!($i % 3)) echo "Fizz\n"; else if (!($i % 5)) echo "Buzz\n"; else echo "$i\n"; } ?>
Ensure the translated PHP code behaves exactly like the original Delphi snippet.
program FizzBuzz; uses SysUtils; var i: Integer; begin for i := 1 to 100 do begin if i mod 15 = 0 then Writeln('FizzBuzz') else if i mod 3 = 0 then Writeln('Fizz') else if i mod 5 = 0 then Writeln('Buzz') else Writeln(i); end; end.
<?php for ($i = 1; $i <= 100; $i++) { if (!($i % 15)) echo "FizzBuzz\n"; else if (!($i % 3)) echo "Fizz\n"; else if (!($i % 5)) echo "Buzz\n"; else echo "$i\n"; } ?>
Write the same algorithm in PHP as shown in this Elixir implementation.
Enum.each 1..100, fn x -> IO.puts(case { rem(x,3) == 0, rem(x,5) == 0 } do { true, true } -> "FizzBuzz" { true, false } -> "Fizz" { false, true } -> "Buzz" { false, false } -> x end) end
<?php for ($i = 1; $i <= 100; $i++) { if (!($i % 15)) echo "FizzBuzz\n"; else if (!($i % 3)) echo "Fizz\n"; else if (!($i % 5)) echo "Buzz\n"; else echo "$i\n"; } ?>
Can you help me rewrite this code in PHP instead of Erlang, keeping it the same logically?
-spec fizzbuzz() -> Result :: string(). fizzbuzz() -> F = fun(N) when N rem 15 == 0 -> "FizzBuzz"; (N) when N rem 3 == 0 -> "Fizz"; (N) when N rem 5 == 0 -> "Buzz"; (N) -> integer_to_list(N) end, lists:flatten([[F(N)] ++ ["\n"] || N <- lists:seq(1,100)]).
<?php for ($i = 1; $i <= 100; $i++) { if (!($i % 15)) echo "FizzBuzz\n"; else if (!($i % 3)) echo "Fizz\n"; else if (!($i % 5)) echo "Buzz\n"; else echo "$i\n"; } ?>
Can you help me rewrite this code in PHP instead of F#, keeping it the same logically?
let fizzbuzz n = match n%3 = 0, n%5 = 0 with | true, false -> "fizz" | false, true -> "buzz" | true, true -> "fizzbuzz" | _ -> string n let printFizzbuzz() = [1..100] |> List.iter (fizzbuzz >> printfn "%s")
<?php for ($i = 1; $i <= 100; $i++) { if (!($i % 15)) echo "FizzBuzz\n"; else if (!($i % 3)) echo "Fizz\n"; else if (!($i % 5)) echo "Buzz\n"; else echo "$i\n"; } ?>
Convert the following code from Factor to PHP, ensuring the logic remains intact.
USING: math kernel io math.functions math.parser math.ranges ; IN: fizzbuzz : fizz ( n -- str ) 3 divisor? "Fizz" "" ? ; : buzz ( n -- str ) 5 divisor? "Buzz" "" ? ; : fizzbuzz ( n -- str ) dup [ fizz ] [ buzz ] bi append [ number>string ] [ nip ] if-empty ; : main ( -- ) 100 [1,b] [ fizzbuzz print ] each ; MAIN: main
<?php for ($i = 1; $i <= 100; $i++) { if (!($i % 15)) echo "FizzBuzz\n"; else if (!($i % 3)) echo "Fizz\n"; else if (!($i % 5)) echo "Buzz\n"; else echo "$i\n"; } ?>
Generate a PHP translation of this Forth snippet without changing its computational steps.
with: n : num? if drop else . then ; : div? mod 0 = dup ; : fizz? dup 3 div? if "Fizz" . then ; : buzz? over 5 div? if "Buzz" . then or ; : fizzbuzz fizz? buzz? num? space ; ' fizzbuzz 1 100 loop cr bye
<?php for ($i = 1; $i <= 100; $i++) { if (!($i % 15)) echo "FizzBuzz\n"; else if (!($i % 3)) echo "Fizz\n"; else if (!($i % 5)) echo "Buzz\n"; else echo "$i\n"; } ?>
Please provide an equivalent version of this Fortran code in PHP.
program fizzbuzz_if integer :: i do i = 1, 100 if (mod(i,15) == 0) then; print *, 'FizzBuzz' else if (mod(i,3) == 0) then; print *, 'Fizz' else if (mod(i,5) == 0) then; print *, 'Buzz' else; print *, i end if end do end program fizzbuzz_if
<?php for ($i = 1; $i <= 100; $i++) { if (!($i % 15)) echo "FizzBuzz\n"; else if (!($i % 3)) echo "Fizz\n"; else if (!($i % 5)) echo "Buzz\n"; else echo "$i\n"; } ?>
Change the programming language of this snippet from Groovy to PHP without modifying what it does.
1.upto(100) { i -> println "${i % 3 ? '' : 'Fizz'}${i % 5 ? '' : 'Buzz'}" ?: i }
<?php for ($i = 1; $i <= 100; $i++) { if (!($i % 15)) echo "FizzBuzz\n"; else if (!($i % 3)) echo "Fizz\n"; else if (!($i % 5)) echo "Buzz\n"; else echo "$i\n"; } ?>
Write the same algorithm in PHP as shown in this Haskell implementation.
fizzbuzz :: Int -> String fizzbuzz x | f 15 = "FizzBuzz" | f 3 = "Fizz" | f 5 = "Buzz" | otherwise = show x where f = (0 ==) . rem x main :: IO () main = mapM_ (putStrLn . fizzbuzz) [1 .. 100]
<?php for ($i = 1; $i <= 100; $i++) { if (!($i % 15)) echo "FizzBuzz\n"; else if (!($i % 3)) echo "Fizz\n"; else if (!($i % 5)) echo "Buzz\n"; else echo "$i\n"; } ?>
Rewrite the snippet below in PHP so it works the same as the original Icon code.
procedure main() every i := 1 to 100 do if i % 15 = 0 then write("FizzBuzz") else if i % 5 = 0 then write("Buzz") else if i % 3 = 0 then write("Fizz") else write(i) end
<?php for ($i = 1; $i <= 100; $i++) { if (!($i % 15)) echo "FizzBuzz\n"; else if (!($i % 3)) echo "Fizz\n"; else if (!($i % 5)) echo "Buzz\n"; else echo "$i\n"; } ?>
Translate the given J code snippet into PHP without altering its behavior.
classify =: +/@(1 2 * 0 = 3 5&|~) (":@]`('Fizz'"_)`('Buzz'"_)`('FizzBuzz'"_) @. classify "0) >:i.100
<?php for ($i = 1; $i <= 100; $i++) { if (!($i % 15)) echo "FizzBuzz\n"; else if (!($i % 3)) echo "Fizz\n"; else if (!($i % 5)) echo "Buzz\n"; else echo "$i\n"; } ?>
Keep all operations the same but rewrite the snippet in PHP.
for i in 1:100 if i % 15 == 0 println("FizzBuzz") elseif i % 3 == 0 println("Fizz") elseif i % 5 == 0 println("Buzz") else println(i) end end
<?php for ($i = 1; $i <= 100; $i++) { if (!($i % 15)) echo "FizzBuzz\n"; else if (!($i % 3)) echo "Fizz\n"; else if (!($i % 5)) echo "Buzz\n"; else echo "$i\n"; } ?>
Write the same algorithm in PHP as shown in this Lua implementation.
for i = 1, 100 do if i % 15 == 0 then print("FizzBuzz") elseif i % 3 == 0 then print("Fizz") elseif i % 5 == 0 then print("Buzz") else print(i) end end
<?php for ($i = 1; $i <= 100; $i++) { if (!($i % 15)) echo "FizzBuzz\n"; else if (!($i % 3)) echo "Fizz\n"; else if (!($i % 5)) echo "Buzz\n"; else echo "$i\n"; } ?>
Port the provided Mathematica code into PHP while preserving the original functionality.
Do[Print[Which[Mod[i, 15] == 0, "FizzBuzz", Mod[i, 5] == 0, "Buzz", Mod[i, 3] == 0, "Fizz", True, i]], {i, 100}]
<?php for ($i = 1; $i <= 100; $i++) { if (!($i % 15)) echo "FizzBuzz\n"; else if (!($i % 3)) echo "Fizz\n"; else if (!($i % 5)) echo "Buzz\n"; else echo "$i\n"; } ?>
Produce a language-to-language conversion: from MATLAB to PHP, same semantics.
function fizzBuzz() for i = (1:100) if mod(i,15) == 0 fprintf('FizzBuzz ') elseif mod(i,3) == 0 fprintf('Fizz ') elseif mod(i,5) == 0 fprintf('Buzz ') else fprintf(' end end fprintf('\n'); end
<?php for ($i = 1; $i <= 100; $i++) { if (!($i % 15)) echo "FizzBuzz\n"; else if (!($i % 3)) echo "Fizz\n"; else if (!($i % 5)) echo "Buzz\n"; else echo "$i\n"; } ?>
Convert this Nim snippet to PHP and keep its semantics consistent.
for i in 1..100: if i mod 15 == 0: echo("FizzBuzz") elif i mod 3 == 0: echo("Fizz") elif i mod 5 == 0: echo("Buzz") else: echo(i)
<?php for ($i = 1; $i <= 100; $i++) { if (!($i % 15)) echo "FizzBuzz\n"; else if (!($i % 3)) echo "Fizz\n"; else if (!($i % 5)) echo "Buzz\n"; else echo "$i\n"; } ?>
Rewrite the snippet below in PHP so it works the same as the original OCaml code.
let format (n : Int) : Latin1 = if (n mod 3 = 0) || (n mod 5 = 0) then "FizzBuzz" else if (n mod 5 = 0) then "Buzz" else if (n mod 3 = 0) then "Fizz" else string_of (n);; let fizz (n : Int, size : Int) : _ = print (format (n) @ "\n"); if (n = size) then n = 0 else fizz(n...
<?php for ($i = 1; $i <= 100; $i++) { if (!($i % 15)) echo "FizzBuzz\n"; else if (!($i % 3)) echo "Fizz\n"; else if (!($i % 5)) echo "Buzz\n"; else echo "$i\n"; } ?>
Generate a PHP translation of this Pascal snippet without changing its computational steps.
program fizzbuzz(output); var i: integer; begin for i := 1 to 100 do if i mod 15 = 0 then writeln('FizzBuzz') else if i mod 3 = 0 then writeln('Fizz') else if i mod 5 = 0 then writeln('Buzz') else writeln(i) end.
<?php for ($i = 1; $i <= 100; $i++) { if (!($i % 15)) echo "FizzBuzz\n"; else if (!($i % 3)) echo "Fizz\n"; else if (!($i % 5)) echo "Buzz\n"; else echo "$i\n"; } ?>
Port the following code from Perl to PHP with equivalent syntax and logic.
use strict; use warnings; use feature qw(say); for my $i (1..100) { say $i % 15 == 0 ? "FizzBuzz" : $i % 3 == 0 ? "Fizz" : $i % 5 == 0 ? "Buzz" : $i; }
<?php for ($i = 1; $i <= 100; $i++) { if (!($i % 15)) echo "FizzBuzz\n"; else if (!($i % 3)) echo "Fizz\n"; else if (!($i % 5)) echo "Buzz\n"; else echo "$i\n"; } ?>