Instruction stringlengths 45 106 | input_code stringlengths 1 13.7k | output_code stringlengths 1 13.7k |
|---|---|---|
Port the provided Delphi code into PHP while preserving the original functionality. | procedure FloatLiterals(Memo: TMemo);
var R48: Real48;
var SI: Single;
var D: Double;
var E: Extended;
var Cmp: Comp;
var Cur: Currency;
begin
D:=1234;
D:=1.234;
D:=1234E-4;
D:=$7F;
D:=123456789.1234;
Memo.Lines.Add(FloatToStrF(D,ffGeneral,18,4));
Memo.Lines.Add(FloatToStrF(D,ffExponent,18,4));
Memo.Lines.A... | .12
0.1234
1.2e3
7E-10
|
Generate an equivalent PHP version of this Elixir code. | iex(180)> 0.123
0.123
iex(181)> -123.4
-123.4
iex(182)> 1.23e4
1.23e4
iex(183)> 1.2e-3
0.0012
iex(184)> 1.23E4
1.23e4
iex(185)> 10_000.0
1.0e4
iex(186)> .5
** (SyntaxError) iex:186: syntax error before: '.'
iex(186)> 2. + 3
** (CompileError) iex:186: invalid call 2.+(3)
iex(187)> 1e4
** (SyntaxError) iex:187: syntax ... | .12
0.1234
1.2e3
7E-10
|
Preserve the algorithm and functionality while converting the code from Factor to PHP. | 3.14
+3.14
-3.14
10e5
10E+5
+10e-5
1.
.5
1/2.
1/3.
1/0.
-1/0.
0/0.
0x1.0p3
-0x1.0P-3
0b1.010001p3
0o1.21p3
1,2... | .12
0.1234
1.2e3
7E-10
|
Translate this program into PHP but keep the logic exactly as in Groovy. | println 1.00f
println 1.00d
println 1.00
println 1.00g
println 1.00e0
assert 1.00f instanceof Float
assert 1.00d instanceof Double
assert 1.00 instanceof BigDecimal
assert 1.00g instanceof BigDecimal
assert 1.00e0 instanceof BigDecimal
| .12
0.1234
1.2e3
7E-10
|
Transform the following Haskell implementation into PHP, maintaining the same output and logic. | main = print [0.1,23.3,35e-1,56E+2,14.67e1]
| .12
0.1234
1.2e3
7E-10
|
Port the following code from Icon to PHP with equivalent syntax and logic. | procedure main()
every write( ![ 1., .1, 0.1, 2e10, 2E10, 3e-1, .4e2, 1.41e2, 8.e+3, 3.141e43 ])
end
| .12
0.1234
1.2e3
7E-10
|
Translate this program into PHP but keep the logic exactly as in J. | 0 1 _2 3.4 3e4 3p4 3x4
0 1 _2 3.4 30000 292.227 163.794
16bcafe.babe _16b_cafe.babe _10b11
51966.7 46818.7 _9
| .12
0.1234
1.2e3
7E-10
|
Translate the given Julia code snippet into PHP without altering its behavior. | 0.1
.1
1.
1e-1
1e+10
1e-10
0x01p-1
| .12
0.1234
1.2e3
7E-10
|
Generate an equivalent PHP version of this Mathematica code. | These numbers are given in the default output format. Large numbers are given in scientific notation.
{6.7^-4,6.7^6,6.7^8}
{0.00049625,90458.4,4.06068*10^6}
This gives all numbers in scientific notation.
ScientificForm[%]
{4.9625*10^(-4),9.04584*10^(4),4.06068*10^(6)}
This gives the numbers in engineering notation,... | .12
0.1234
1.2e3
7E-10
|
Ensure the translated PHP code behaves exactly like the original Nim snippet. | var x: float
x = 2.3
x = 2.0
x = 0.3
x = 123_456_789.000_000_1
x = 2e10
x = 2.5e10
x = 2.523_123E10
x = 5.2e-10
var y = 2'f32
var z = 2'f64
| .12
0.1234
1.2e3
7E-10
|
Generate an equivalent PHP version of this OCaml code. | 0.5
1.0
1.
1e-10
3.14159_26535_89793
| .12
0.1234
1.2e3
7E-10
|
Translate this program into PHP but keep the logic exactly as in Perl. |
.5;
0.5;
1.23345e10;
1.23445e-10;
100_000_000;
| .12
0.1234
1.2e3
7E-10
|
Translate this program into PHP but keep the logic exactly as in Racket. | #lang racket
.2
2.
2.+0i
2e0
#x10.8
#o1e2
2.0f0
1.0t0
| .12
0.1234
1.2e3
7E-10
|
Write a version of this REXX function in PHP with identical behavior. |
options replace format comments java crossref symbols nobinary
numeric digits 40 -- make lots of space for big numbers
numeric form scientific -- set output form for exponential notation
say 'Sample using objects of type "Rexx" (default):'
fv = 1.5; say '1.5'.right(20) '==' normalize(fv).right(20) -- ... | .12
0.1234
1.2e3
7E-10
|
Write the same algorithm in PHP as shown in this Ruby implementation. | say 1.234;
say .1234;
say 1234e-5;
say 12.34e5;
| .12
0.1234
1.2e3
7E-10
|
Produce a functionally identical PHP code for the snippet given in Scala. | 1.
1.0
2432311.7567374
1.234E-10
1.234e-10
758832d
728832f
1.0f
758832D
728832F
1.0F
1 / 2.
1 / 2
Float.MinPositiveValue
Float.NaN
Float.PositiveInfinity
Float.NegativeInfinity
Double.MinPositiveValue
Double.NaN
Double.PositiveInfinity
Double.NegativeInfinity
| .12
0.1234
1.2e3
7E-10
|
Can you help me rewrite this code in PHP instead of Swift, keeping it the same logically? | let double = 1.0 as Double
let float = 1.0 as Float
let scientific = 1.0E-12
let sum = double + float
let div = 1.1 / 2
let div1 = 1 / 2
| .12
0.1234
1.2e3
7E-10
|
Write the same algorithm in Rust as shown in this C# implementation. | double d = 1;
d = 1d;
d = 1D;
d = 1.2;
d = 1.2d;
d = .2;
d = 12e-12;
d = 12E-12;
d = 1_234e-1_2;
float f = 1;
f = 1f;
f = 1F;
f = 1.2f;
f = .2f;
f = 12e-12f;
f = 12E-12f;
f = 1_234e-1_2f;
decimal m = 1;
m = 1m;
m = 1m;
m = 1.2m;
m = .2m;
m = 12e-12m;
m = 12E-12m;
m = 1_234e-1_2m;
| 2.3
3.
2f64
1_000.2_f32
|
Change the following Java code into Rust without altering its purpose. | 1.
1.0
2432311.7567374
1.234E-10
1.234e-10
758832d
728832f
1.0f
758832D
728832F
1.0F
1 / 2.
1 / 2
| 2.3
3.
2f64
1_000.2_f32
|
Generate an equivalent Python version of this Rust code. | 2.3
3.
2f64
1_000.2_f32
| 2.3
.3
.3e4
.3e+34
.3e-34
2.e34
|
Write the same code in VB as shown below in Rust. | 2.3
3.
2f64
1_000.2_f32
| Sub Main()
Dim d As Double
Dim s As Single
d = -12.3456
d = 1000#
d = 0.00001
d = 67#
d = 8.9
d = 0.33
d = 0#
d = 2# * 10 ^ 3
d = 2E+50
d = 2E-50
s = -12.3456!
s = 1000!
s = 0.00001!
s = 67!
s = 8.9!
s = 0.33!
s = 0!
s = 2! * 10 ^ 3
End Sub
|
Port the following code from C++ to Rust with equivalent syntax and logic. | #include <iostream>
int main()
{
auto double1 = 2.5;
auto float1 = 2.5f;
auto longdouble1 = 2.5l;
auto double2 = 2.5e-3;
auto float2 = 2.5e3f;
auto double3 = 0x1p4;
auto float3 = 0xbeefp-8f;
std::cout << "\ndouble1: " << double1;
std::cout << "\nfloat1: " << float1;
std::cout <<... | 2.3
3.
2f64
1_000.2_f32
|
Generate a C# translation of this Ada snippet without changing its computational steps. | with Ada.Text_IO, Generic_Divisors;
procedure Odd_Abundant is
function Same(P: Positive) return Positive is (P);
package Divisor_Sum is new Generic_Divisors
(Result_Type => Natural, None => 0, One => Same, Add => "+");
function Abundant(N: Positive) return Boolean is
(Divisor_Sum.Process(N... | using static System.Console;
using System.Collections.Generic;
using System.Linq;
public static class AbundantOddNumbers
{
public static void Main() {
WriteLine("First 25 abundant odd numbers:");
foreach (var x in AbundantNumbers().Take(25)) WriteLine(x.Format());
WriteLine();
Write... |
Generate an equivalent C# version of this Ada code. | with Ada.Text_IO, Generic_Divisors;
procedure Odd_Abundant is
function Same(P: Positive) return Positive is (P);
package Divisor_Sum is new Generic_Divisors
(Result_Type => Natural, None => 0, One => Same, Add => "+");
function Abundant(N: Positive) return Boolean is
(Divisor_Sum.Process(N... | using static System.Console;
using System.Collections.Generic;
using System.Linq;
public static class AbundantOddNumbers
{
public static void Main() {
WriteLine("First 25 abundant odd numbers:");
foreach (var x in AbundantNumbers().Take(25)) WriteLine(x.Format());
WriteLine();
Write... |
Convert the following code from Ada to C, ensuring the logic remains intact. | with Ada.Text_IO, Generic_Divisors;
procedure Odd_Abundant is
function Same(P: Positive) return Positive is (P);
package Divisor_Sum is new Generic_Divisors
(Result_Type => Natural, None => 0, One => Same, Add => "+");
function Abundant(N: Positive) return Boolean is
(Divisor_Sum.Process(N... | #include <stdio.h>
#include <math.h>
unsigned sum_proper_divisors(const unsigned n) {
unsigned sum = 1;
for (unsigned i = 3, j; i < sqrt(n)+1; i += 2) if (n % i == 0) sum += i + (i == (j = n / i) ? 0 : j);
return sum;
}
int main(int argc, char const *argv[]) {
unsigned n, c;
for (n = 1, c = 0; c < 25; n +... |
Ensure the translated C code behaves exactly like the original Ada snippet. | with Ada.Text_IO, Generic_Divisors;
procedure Odd_Abundant is
function Same(P: Positive) return Positive is (P);
package Divisor_Sum is new Generic_Divisors
(Result_Type => Natural, None => 0, One => Same, Add => "+");
function Abundant(N: Positive) return Boolean is
(Divisor_Sum.Process(N... | #include <stdio.h>
#include <math.h>
unsigned sum_proper_divisors(const unsigned n) {
unsigned sum = 1;
for (unsigned i = 3, j; i < sqrt(n)+1; i += 2) if (n % i == 0) sum += i + (i == (j = n / i) ? 0 : j);
return sum;
}
int main(int argc, char const *argv[]) {
unsigned n, c;
for (n = 1, c = 0; c < 25; n +... |
Write the same algorithm in C++ as shown in this Ada implementation. | with Ada.Text_IO, Generic_Divisors;
procedure Odd_Abundant is
function Same(P: Positive) return Positive is (P);
package Divisor_Sum is new Generic_Divisors
(Result_Type => Natural, None => 0, One => Same, Add => "+");
function Abundant(N: Positive) return Boolean is
(Divisor_Sum.Process(N... | #include <algorithm>
#include <iostream>
#include <numeric>
#include <sstream>
#include <vector>
std::vector<int> divisors(int n) {
std::vector<int> divs{ 1 };
std::vector<int> divs2;
for (int i = 2; i*i <= n; i++) {
if (n%i == 0) {
int j = n / i;
divs.push_back(i);
... |
Convert this Ada block to C++, preserving its control flow and logic. | with Ada.Text_IO, Generic_Divisors;
procedure Odd_Abundant is
function Same(P: Positive) return Positive is (P);
package Divisor_Sum is new Generic_Divisors
(Result_Type => Natural, None => 0, One => Same, Add => "+");
function Abundant(N: Positive) return Boolean is
(Divisor_Sum.Process(N... | #include <algorithm>
#include <iostream>
#include <numeric>
#include <sstream>
#include <vector>
std::vector<int> divisors(int n) {
std::vector<int> divs{ 1 };
std::vector<int> divs2;
for (int i = 2; i*i <= n; i++) {
if (n%i == 0) {
int j = n / i;
divs.push_back(i);
... |
Keep all operations the same but rewrite the snippet in Go. | with Ada.Text_IO, Generic_Divisors;
procedure Odd_Abundant is
function Same(P: Positive) return Positive is (P);
package Divisor_Sum is new Generic_Divisors
(Result_Type => Natural, None => 0, One => Same, Add => "+");
function Abundant(N: Positive) return Boolean is
(Divisor_Sum.Process(N... | package main
import (
"fmt"
"strconv"
)
func divisors(n int) []int {
divs := []int{1}
divs2 := []int{}
for i := 2; i*i <= n; i++ {
if n%i == 0 {
j := n / i
divs = append(divs, i)
if i != j {
divs2 = append(divs2, j)
}
... |
Write a version of this Ada function in Go with identical behavior. | with Ada.Text_IO, Generic_Divisors;
procedure Odd_Abundant is
function Same(P: Positive) return Positive is (P);
package Divisor_Sum is new Generic_Divisors
(Result_Type => Natural, None => 0, One => Same, Add => "+");
function Abundant(N: Positive) return Boolean is
(Divisor_Sum.Process(N... | package main
import (
"fmt"
"strconv"
)
func divisors(n int) []int {
divs := []int{1}
divs2 := []int{}
for i := 2; i*i <= n; i++ {
if n%i == 0 {
j := n / i
divs = append(divs, i)
if i != j {
divs2 = append(divs2, j)
}
... |
Rewrite the snippet below in Java so it works the same as the original Ada code. | with Ada.Text_IO, Generic_Divisors;
procedure Odd_Abundant is
function Same(P: Positive) return Positive is (P);
package Divisor_Sum is new Generic_Divisors
(Result_Type => Natural, None => 0, One => Same, Add => "+");
function Abundant(N: Positive) return Boolean is
(Divisor_Sum.Process(N... | import java.util.ArrayList;
import java.util.List;
public class AbundantOddNumbers {
private static List<Integer> list = new ArrayList<>();
private static List<Integer> result = new ArrayList<>();
public static void main(String[] args) {
System.out.println("First 25: ");
abundantOdd(1,1000... |
Write a version of this Ada function in Java with identical behavior. | with Ada.Text_IO, Generic_Divisors;
procedure Odd_Abundant is
function Same(P: Positive) return Positive is (P);
package Divisor_Sum is new Generic_Divisors
(Result_Type => Natural, None => 0, One => Same, Add => "+");
function Abundant(N: Positive) return Boolean is
(Divisor_Sum.Process(N... | import java.util.ArrayList;
import java.util.List;
public class AbundantOddNumbers {
private static List<Integer> list = new ArrayList<>();
private static List<Integer> result = new ArrayList<>();
public static void main(String[] args) {
System.out.println("First 25: ");
abundantOdd(1,1000... |
Convert this Ada snippet to Python and keep its semantics consistent. | with Ada.Text_IO, Generic_Divisors;
procedure Odd_Abundant is
function Same(P: Positive) return Positive is (P);
package Divisor_Sum is new Generic_Divisors
(Result_Type => Natural, None => 0, One => Same, Add => "+");
function Abundant(N: Positive) return Boolean is
(Divisor_Sum.Process(N... |
oddNumber = 1
aCount = 0
dSum = 0
from math import sqrt
def divisorSum(n):
sum = 1
i = int(sqrt(n)+1)
for d in range (2, i):
if n % d == 0:
sum += d
otherD = n // d
if otherD != d:
sum += otherD
return sum
print ("The first 25 abu... |
Generate an equivalent Python version of this Ada code. | with Ada.Text_IO, Generic_Divisors;
procedure Odd_Abundant is
function Same(P: Positive) return Positive is (P);
package Divisor_Sum is new Generic_Divisors
(Result_Type => Natural, None => 0, One => Same, Add => "+");
function Abundant(N: Positive) return Boolean is
(Divisor_Sum.Process(N... |
oddNumber = 1
aCount = 0
dSum = 0
from math import sqrt
def divisorSum(n):
sum = 1
i = int(sqrt(n)+1)
for d in range (2, i):
if n % d == 0:
sum += d
otherD = n // d
if otherD != d:
sum += otherD
return sum
print ("The first 25 abu... |
Convert this Ada block to VB, preserving its control flow and logic. | with Ada.Text_IO, Generic_Divisors;
procedure Odd_Abundant is
function Same(P: Positive) return Positive is (P);
package Divisor_Sum is new Generic_Divisors
(Result_Type => Natural, None => 0, One => Same, Add => "+");
function Abundant(N: Positive) return Boolean is
(Divisor_Sum.Process(N... | Module AbundantOddNumbers
Private Function divisorSum(n As Integer) As Integer
Dim sum As Integer = 1
For d As Integer = 2 To Math.Round(Math.Sqrt(n))
If n Mod d = 0 Then
sum += d
Dim otherD As Integer = n \ d
IF otherD... |
Change the programming language of this snippet from Ada to VB without modifying what it does. | with Ada.Text_IO, Generic_Divisors;
procedure Odd_Abundant is
function Same(P: Positive) return Positive is (P);
package Divisor_Sum is new Generic_Divisors
(Result_Type => Natural, None => 0, One => Same, Add => "+");
function Abundant(N: Positive) return Boolean is
(Divisor_Sum.Process(N... | Module AbundantOddNumbers
Private Function divisorSum(n As Integer) As Integer
Dim sum As Integer = 1
For d As Integer = 2 To Math.Round(Math.Sqrt(n))
If n Mod d = 0 Then
sum += d
Dim otherD As Integer = n \ d
IF otherD... |
Write a version of this Arturo function in C with identical behavior. | abundant?: function [n]-> (2*n) < sum factors n
print "the first 25 abundant odd numbers:"
[i, found]: @[new 1, new 0]
while [found<25][
if abundant? i [
inc 'found
print [i "=> sum:" sum factors i]
]
'i + 2
]
[i, found]: @[new 1, new 0]
while [found<1000][
if abundant? i [
inc... | #include <stdio.h>
#include <math.h>
unsigned sum_proper_divisors(const unsigned n) {
unsigned sum = 1;
for (unsigned i = 3, j; i < sqrt(n)+1; i += 2) if (n % i == 0) sum += i + (i == (j = n / i) ? 0 : j);
return sum;
}
int main(int argc, char const *argv[]) {
unsigned n, c;
for (n = 1, c = 0; c < 25; n +... |
Port the following code from Arturo to C with equivalent syntax and logic. | abundant?: function [n]-> (2*n) < sum factors n
print "the first 25 abundant odd numbers:"
[i, found]: @[new 1, new 0]
while [found<25][
if abundant? i [
inc 'found
print [i "=> sum:" sum factors i]
]
'i + 2
]
[i, found]: @[new 1, new 0]
while [found<1000][
if abundant? i [
inc... | #include <stdio.h>
#include <math.h>
unsigned sum_proper_divisors(const unsigned n) {
unsigned sum = 1;
for (unsigned i = 3, j; i < sqrt(n)+1; i += 2) if (n % i == 0) sum += i + (i == (j = n / i) ? 0 : j);
return sum;
}
int main(int argc, char const *argv[]) {
unsigned n, c;
for (n = 1, c = 0; c < 25; n +... |
Translate the given Arturo code snippet into C# without altering its behavior. | abundant?: function [n]-> (2*n) < sum factors n
print "the first 25 abundant odd numbers:"
[i, found]: @[new 1, new 0]
while [found<25][
if abundant? i [
inc 'found
print [i "=> sum:" sum factors i]
]
'i + 2
]
[i, found]: @[new 1, new 0]
while [found<1000][
if abundant? i [
inc... | using static System.Console;
using System.Collections.Generic;
using System.Linq;
public static class AbundantOddNumbers
{
public static void Main() {
WriteLine("First 25 abundant odd numbers:");
foreach (var x in AbundantNumbers().Take(25)) WriteLine(x.Format());
WriteLine();
Write... |
Write the same code in C# as shown below in Arturo. | abundant?: function [n]-> (2*n) < sum factors n
print "the first 25 abundant odd numbers:"
[i, found]: @[new 1, new 0]
while [found<25][
if abundant? i [
inc 'found
print [i "=> sum:" sum factors i]
]
'i + 2
]
[i, found]: @[new 1, new 0]
while [found<1000][
if abundant? i [
inc... | using static System.Console;
using System.Collections.Generic;
using System.Linq;
public static class AbundantOddNumbers
{
public static void Main() {
WriteLine("First 25 abundant odd numbers:");
foreach (var x in AbundantNumbers().Take(25)) WriteLine(x.Format());
WriteLine();
Write... |
Maintain the same structure and functionality when rewriting this code in C++. | abundant?: function [n]-> (2*n) < sum factors n
print "the first 25 abundant odd numbers:"
[i, found]: @[new 1, new 0]
while [found<25][
if abundant? i [
inc 'found
print [i "=> sum:" sum factors i]
]
'i + 2
]
[i, found]: @[new 1, new 0]
while [found<1000][
if abundant? i [
inc... | #include <algorithm>
#include <iostream>
#include <numeric>
#include <sstream>
#include <vector>
std::vector<int> divisors(int n) {
std::vector<int> divs{ 1 };
std::vector<int> divs2;
for (int i = 2; i*i <= n; i++) {
if (n%i == 0) {
int j = n / i;
divs.push_back(i);
... |
Change the following Arturo code into C++ without altering its purpose. | abundant?: function [n]-> (2*n) < sum factors n
print "the first 25 abundant odd numbers:"
[i, found]: @[new 1, new 0]
while [found<25][
if abundant? i [
inc 'found
print [i "=> sum:" sum factors i]
]
'i + 2
]
[i, found]: @[new 1, new 0]
while [found<1000][
if abundant? i [
inc... | #include <algorithm>
#include <iostream>
#include <numeric>
#include <sstream>
#include <vector>
std::vector<int> divisors(int n) {
std::vector<int> divs{ 1 };
std::vector<int> divs2;
for (int i = 2; i*i <= n; i++) {
if (n%i == 0) {
int j = n / i;
divs.push_back(i);
... |
Translate the given Arturo code snippet into Java without altering its behavior. | abundant?: function [n]-> (2*n) < sum factors n
print "the first 25 abundant odd numbers:"
[i, found]: @[new 1, new 0]
while [found<25][
if abundant? i [
inc 'found
print [i "=> sum:" sum factors i]
]
'i + 2
]
[i, found]: @[new 1, new 0]
while [found<1000][
if abundant? i [
inc... | import java.util.ArrayList;
import java.util.List;
public class AbundantOddNumbers {
private static List<Integer> list = new ArrayList<>();
private static List<Integer> result = new ArrayList<>();
public static void main(String[] args) {
System.out.println("First 25: ");
abundantOdd(1,1000... |
Can you help me rewrite this code in Java instead of Arturo, keeping it the same logically? | abundant?: function [n]-> (2*n) < sum factors n
print "the first 25 abundant odd numbers:"
[i, found]: @[new 1, new 0]
while [found<25][
if abundant? i [
inc 'found
print [i "=> sum:" sum factors i]
]
'i + 2
]
[i, found]: @[new 1, new 0]
while [found<1000][
if abundant? i [
inc... | import java.util.ArrayList;
import java.util.List;
public class AbundantOddNumbers {
private static List<Integer> list = new ArrayList<>();
private static List<Integer> result = new ArrayList<>();
public static void main(String[] args) {
System.out.println("First 25: ");
abundantOdd(1,1000... |
Generate a Python translation of this Arturo snippet without changing its computational steps. | abundant?: function [n]-> (2*n) < sum factors n
print "the first 25 abundant odd numbers:"
[i, found]: @[new 1, new 0]
while [found<25][
if abundant? i [
inc 'found
print [i "=> sum:" sum factors i]
]
'i + 2
]
[i, found]: @[new 1, new 0]
while [found<1000][
if abundant? i [
inc... |
oddNumber = 1
aCount = 0
dSum = 0
from math import sqrt
def divisorSum(n):
sum = 1
i = int(sqrt(n)+1)
for d in range (2, i):
if n % d == 0:
sum += d
otherD = n // d
if otherD != d:
sum += otherD
return sum
print ("The first 25 abu... |
Write the same code in Python as shown below in Arturo. | abundant?: function [n]-> (2*n) < sum factors n
print "the first 25 abundant odd numbers:"
[i, found]: @[new 1, new 0]
while [found<25][
if abundant? i [
inc 'found
print [i "=> sum:" sum factors i]
]
'i + 2
]
[i, found]: @[new 1, new 0]
while [found<1000][
if abundant? i [
inc... |
oddNumber = 1
aCount = 0
dSum = 0
from math import sqrt
def divisorSum(n):
sum = 1
i = int(sqrt(n)+1)
for d in range (2, i):
if n % d == 0:
sum += d
otherD = n // d
if otherD != d:
sum += otherD
return sum
print ("The first 25 abu... |
Port the following code from Arturo to VB with equivalent syntax and logic. | abundant?: function [n]-> (2*n) < sum factors n
print "the first 25 abundant odd numbers:"
[i, found]: @[new 1, new 0]
while [found<25][
if abundant? i [
inc 'found
print [i "=> sum:" sum factors i]
]
'i + 2
]
[i, found]: @[new 1, new 0]
while [found<1000][
if abundant? i [
inc... | Module AbundantOddNumbers
Private Function divisorSum(n As Integer) As Integer
Dim sum As Integer = 1
For d As Integer = 2 To Math.Round(Math.Sqrt(n))
If n Mod d = 0 Then
sum += d
Dim otherD As Integer = n \ d
IF otherD... |
Convert this Arturo block to VB, preserving its control flow and logic. | abundant?: function [n]-> (2*n) < sum factors n
print "the first 25 abundant odd numbers:"
[i, found]: @[new 1, new 0]
while [found<25][
if abundant? i [
inc 'found
print [i "=> sum:" sum factors i]
]
'i + 2
]
[i, found]: @[new 1, new 0]
while [found<1000][
if abundant? i [
inc... | Module AbundantOddNumbers
Private Function divisorSum(n As Integer) As Integer
Dim sum As Integer = 1
For d As Integer = 2 To Math.Round(Math.Sqrt(n))
If n Mod d = 0 Then
sum += d
Dim otherD As Integer = n \ d
IF otherD... |
Please provide an equivalent version of this Arturo code in Go. | abundant?: function [n]-> (2*n) < sum factors n
print "the first 25 abundant odd numbers:"
[i, found]: @[new 1, new 0]
while [found<25][
if abundant? i [
inc 'found
print [i "=> sum:" sum factors i]
]
'i + 2
]
[i, found]: @[new 1, new 0]
while [found<1000][
if abundant? i [
inc... | package main
import (
"fmt"
"strconv"
)
func divisors(n int) []int {
divs := []int{1}
divs2 := []int{}
for i := 2; i*i <= n; i++ {
if n%i == 0 {
j := n / i
divs = append(divs, i)
if i != j {
divs2 = append(divs2, j)
}
... |
Generate an equivalent Go version of this Arturo code. | abundant?: function [n]-> (2*n) < sum factors n
print "the first 25 abundant odd numbers:"
[i, found]: @[new 1, new 0]
while [found<25][
if abundant? i [
inc 'found
print [i "=> sum:" sum factors i]
]
'i + 2
]
[i, found]: @[new 1, new 0]
while [found<1000][
if abundant? i [
inc... | package main
import (
"fmt"
"strconv"
)
func divisors(n int) []int {
divs := []int{1}
divs2 := []int{}
for i := 2; i*i <= n; i++ {
if n%i == 0 {
j := n / i
divs = append(divs, i)
if i != j {
divs2 = append(divs2, j)
}
... |
Port the provided AutoHotKey code into C while preserving the original functionality. | Abundant(num){
sum := 0, str := ""
for n, bool in proper_divisors(num)
sum += n, str .= (str?"+":"") n
return sum > num ? str " = " sum : 0
}
proper_divisors(n) {
Array := []
if n = 1
return Array
Array[1] := true
x := Floor(Sqrt(n))
loop, % x+1
if !Mod(n, i:=A_Index+1) && (floor(n/i) < n)
Array[floor... | #include <stdio.h>
#include <math.h>
unsigned sum_proper_divisors(const unsigned n) {
unsigned sum = 1;
for (unsigned i = 3, j; i < sqrt(n)+1; i += 2) if (n % i == 0) sum += i + (i == (j = n / i) ? 0 : j);
return sum;
}
int main(int argc, char const *argv[]) {
unsigned n, c;
for (n = 1, c = 0; c < 25; n +... |
Translate this program into C but keep the logic exactly as in AutoHotKey. | Abundant(num){
sum := 0, str := ""
for n, bool in proper_divisors(num)
sum += n, str .= (str?"+":"") n
return sum > num ? str " = " sum : 0
}
proper_divisors(n) {
Array := []
if n = 1
return Array
Array[1] := true
x := Floor(Sqrt(n))
loop, % x+1
if !Mod(n, i:=A_Index+1) && (floor(n/i) < n)
Array[floor... | #include <stdio.h>
#include <math.h>
unsigned sum_proper_divisors(const unsigned n) {
unsigned sum = 1;
for (unsigned i = 3, j; i < sqrt(n)+1; i += 2) if (n % i == 0) sum += i + (i == (j = n / i) ? 0 : j);
return sum;
}
int main(int argc, char const *argv[]) {
unsigned n, c;
for (n = 1, c = 0; c < 25; n +... |
Maintain the same structure and functionality when rewriting this code in C#. | Abundant(num){
sum := 0, str := ""
for n, bool in proper_divisors(num)
sum += n, str .= (str?"+":"") n
return sum > num ? str " = " sum : 0
}
proper_divisors(n) {
Array := []
if n = 1
return Array
Array[1] := true
x := Floor(Sqrt(n))
loop, % x+1
if !Mod(n, i:=A_Index+1) && (floor(n/i) < n)
Array[floor... | using static System.Console;
using System.Collections.Generic;
using System.Linq;
public static class AbundantOddNumbers
{
public static void Main() {
WriteLine("First 25 abundant odd numbers:");
foreach (var x in AbundantNumbers().Take(25)) WriteLine(x.Format());
WriteLine();
Write... |
Please provide an equivalent version of this AutoHotKey code in C#. | Abundant(num){
sum := 0, str := ""
for n, bool in proper_divisors(num)
sum += n, str .= (str?"+":"") n
return sum > num ? str " = " sum : 0
}
proper_divisors(n) {
Array := []
if n = 1
return Array
Array[1] := true
x := Floor(Sqrt(n))
loop, % x+1
if !Mod(n, i:=A_Index+1) && (floor(n/i) < n)
Array[floor... | using static System.Console;
using System.Collections.Generic;
using System.Linq;
public static class AbundantOddNumbers
{
public static void Main() {
WriteLine("First 25 abundant odd numbers:");
foreach (var x in AbundantNumbers().Take(25)) WriteLine(x.Format());
WriteLine();
Write... |
Write the same code in C++ as shown below in AutoHotKey. | Abundant(num){
sum := 0, str := ""
for n, bool in proper_divisors(num)
sum += n, str .= (str?"+":"") n
return sum > num ? str " = " sum : 0
}
proper_divisors(n) {
Array := []
if n = 1
return Array
Array[1] := true
x := Floor(Sqrt(n))
loop, % x+1
if !Mod(n, i:=A_Index+1) && (floor(n/i) < n)
Array[floor... | #include <algorithm>
#include <iostream>
#include <numeric>
#include <sstream>
#include <vector>
std::vector<int> divisors(int n) {
std::vector<int> divs{ 1 };
std::vector<int> divs2;
for (int i = 2; i*i <= n; i++) {
if (n%i == 0) {
int j = n / i;
divs.push_back(i);
... |
Generate an equivalent C++ version of this AutoHotKey code. | Abundant(num){
sum := 0, str := ""
for n, bool in proper_divisors(num)
sum += n, str .= (str?"+":"") n
return sum > num ? str " = " sum : 0
}
proper_divisors(n) {
Array := []
if n = 1
return Array
Array[1] := true
x := Floor(Sqrt(n))
loop, % x+1
if !Mod(n, i:=A_Index+1) && (floor(n/i) < n)
Array[floor... | #include <algorithm>
#include <iostream>
#include <numeric>
#include <sstream>
#include <vector>
std::vector<int> divisors(int n) {
std::vector<int> divs{ 1 };
std::vector<int> divs2;
for (int i = 2; i*i <= n; i++) {
if (n%i == 0) {
int j = n / i;
divs.push_back(i);
... |
Keep all operations the same but rewrite the snippet in Java. | Abundant(num){
sum := 0, str := ""
for n, bool in proper_divisors(num)
sum += n, str .= (str?"+":"") n
return sum > num ? str " = " sum : 0
}
proper_divisors(n) {
Array := []
if n = 1
return Array
Array[1] := true
x := Floor(Sqrt(n))
loop, % x+1
if !Mod(n, i:=A_Index+1) && (floor(n/i) < n)
Array[floor... | import java.util.ArrayList;
import java.util.List;
public class AbundantOddNumbers {
private static List<Integer> list = new ArrayList<>();
private static List<Integer> result = new ArrayList<>();
public static void main(String[] args) {
System.out.println("First 25: ");
abundantOdd(1,1000... |
Ensure the translated Java code behaves exactly like the original AutoHotKey snippet. | Abundant(num){
sum := 0, str := ""
for n, bool in proper_divisors(num)
sum += n, str .= (str?"+":"") n
return sum > num ? str " = " sum : 0
}
proper_divisors(n) {
Array := []
if n = 1
return Array
Array[1] := true
x := Floor(Sqrt(n))
loop, % x+1
if !Mod(n, i:=A_Index+1) && (floor(n/i) < n)
Array[floor... | import java.util.ArrayList;
import java.util.List;
public class AbundantOddNumbers {
private static List<Integer> list = new ArrayList<>();
private static List<Integer> result = new ArrayList<>();
public static void main(String[] args) {
System.out.println("First 25: ");
abundantOdd(1,1000... |
Change the programming language of this snippet from AutoHotKey to Python without modifying what it does. | Abundant(num){
sum := 0, str := ""
for n, bool in proper_divisors(num)
sum += n, str .= (str?"+":"") n
return sum > num ? str " = " sum : 0
}
proper_divisors(n) {
Array := []
if n = 1
return Array
Array[1] := true
x := Floor(Sqrt(n))
loop, % x+1
if !Mod(n, i:=A_Index+1) && (floor(n/i) < n)
Array[floor... |
oddNumber = 1
aCount = 0
dSum = 0
from math import sqrt
def divisorSum(n):
sum = 1
i = int(sqrt(n)+1)
for d in range (2, i):
if n % d == 0:
sum += d
otherD = n // d
if otherD != d:
sum += otherD
return sum
print ("The first 25 abu... |
Generate a Python translation of this AutoHotKey snippet without changing its computational steps. | Abundant(num){
sum := 0, str := ""
for n, bool in proper_divisors(num)
sum += n, str .= (str?"+":"") n
return sum > num ? str " = " sum : 0
}
proper_divisors(n) {
Array := []
if n = 1
return Array
Array[1] := true
x := Floor(Sqrt(n))
loop, % x+1
if !Mod(n, i:=A_Index+1) && (floor(n/i) < n)
Array[floor... |
oddNumber = 1
aCount = 0
dSum = 0
from math import sqrt
def divisorSum(n):
sum = 1
i = int(sqrt(n)+1)
for d in range (2, i):
if n % d == 0:
sum += d
otherD = n // d
if otherD != d:
sum += otherD
return sum
print ("The first 25 abu... |
Can you help me rewrite this code in VB instead of AutoHotKey, keeping it the same logically? | Abundant(num){
sum := 0, str := ""
for n, bool in proper_divisors(num)
sum += n, str .= (str?"+":"") n
return sum > num ? str " = " sum : 0
}
proper_divisors(n) {
Array := []
if n = 1
return Array
Array[1] := true
x := Floor(Sqrt(n))
loop, % x+1
if !Mod(n, i:=A_Index+1) && (floor(n/i) < n)
Array[floor... | Module AbundantOddNumbers
Private Function divisorSum(n As Integer) As Integer
Dim sum As Integer = 1
For d As Integer = 2 To Math.Round(Math.Sqrt(n))
If n Mod d = 0 Then
sum += d
Dim otherD As Integer = n \ d
IF otherD... |
Transform the following AutoHotKey implementation into VB, maintaining the same output and logic. | Abundant(num){
sum := 0, str := ""
for n, bool in proper_divisors(num)
sum += n, str .= (str?"+":"") n
return sum > num ? str " = " sum : 0
}
proper_divisors(n) {
Array := []
if n = 1
return Array
Array[1] := true
x := Floor(Sqrt(n))
loop, % x+1
if !Mod(n, i:=A_Index+1) && (floor(n/i) < n)
Array[floor... | Module AbundantOddNumbers
Private Function divisorSum(n As Integer) As Integer
Dim sum As Integer = 1
For d As Integer = 2 To Math.Round(Math.Sqrt(n))
If n Mod d = 0 Then
sum += d
Dim otherD As Integer = n \ d
IF otherD... |
Convert this AutoHotKey block to Go, preserving its control flow and logic. | Abundant(num){
sum := 0, str := ""
for n, bool in proper_divisors(num)
sum += n, str .= (str?"+":"") n
return sum > num ? str " = " sum : 0
}
proper_divisors(n) {
Array := []
if n = 1
return Array
Array[1] := true
x := Floor(Sqrt(n))
loop, % x+1
if !Mod(n, i:=A_Index+1) && (floor(n/i) < n)
Array[floor... | package main
import (
"fmt"
"strconv"
)
func divisors(n int) []int {
divs := []int{1}
divs2 := []int{}
for i := 2; i*i <= n; i++ {
if n%i == 0 {
j := n / i
divs = append(divs, i)
if i != j {
divs2 = append(divs2, j)
}
... |
Change the following AutoHotKey code into Go without altering its purpose. | Abundant(num){
sum := 0, str := ""
for n, bool in proper_divisors(num)
sum += n, str .= (str?"+":"") n
return sum > num ? str " = " sum : 0
}
proper_divisors(n) {
Array := []
if n = 1
return Array
Array[1] := true
x := Floor(Sqrt(n))
loop, % x+1
if !Mod(n, i:=A_Index+1) && (floor(n/i) < n)
Array[floor... | package main
import (
"fmt"
"strconv"
)
func divisors(n int) []int {
divs := []int{1}
divs2 := []int{}
for i := 2; i*i <= n; i++ {
if n%i == 0 {
j := n / i
divs = append(divs, i)
if i != j {
divs2 = append(divs2, j)
}
... |
Please provide an equivalent version of this AWK code in C. |
BEGIN {
print(" index number sum")
fmt = "%8s %10d %10d\n"
n = 1
for (c=0; c<25; n+=2) {
if (n < sum_proper_divisors(n)) {
printf(fmt,++c,n,sum)
}
}
for (; c<1000; n+=2) {
if (n < sum_proper_divisors(n)) {
c++
}
}
printf(fmt,1000,n-2... | #include <stdio.h>
#include <math.h>
unsigned sum_proper_divisors(const unsigned n) {
unsigned sum = 1;
for (unsigned i = 3, j; i < sqrt(n)+1; i += 2) if (n % i == 0) sum += i + (i == (j = n / i) ? 0 : j);
return sum;
}
int main(int argc, char const *argv[]) {
unsigned n, c;
for (n = 1, c = 0; c < 25; n +... |
Write the same code in C as shown below in AWK. |
BEGIN {
print(" index number sum")
fmt = "%8s %10d %10d\n"
n = 1
for (c=0; c<25; n+=2) {
if (n < sum_proper_divisors(n)) {
printf(fmt,++c,n,sum)
}
}
for (; c<1000; n+=2) {
if (n < sum_proper_divisors(n)) {
c++
}
}
printf(fmt,1000,n-2... | #include <stdio.h>
#include <math.h>
unsigned sum_proper_divisors(const unsigned n) {
unsigned sum = 1;
for (unsigned i = 3, j; i < sqrt(n)+1; i += 2) if (n % i == 0) sum += i + (i == (j = n / i) ? 0 : j);
return sum;
}
int main(int argc, char const *argv[]) {
unsigned n, c;
for (n = 1, c = 0; c < 25; n +... |
Transform the following AWK implementation into C#, maintaining the same output and logic. |
BEGIN {
print(" index number sum")
fmt = "%8s %10d %10d\n"
n = 1
for (c=0; c<25; n+=2) {
if (n < sum_proper_divisors(n)) {
printf(fmt,++c,n,sum)
}
}
for (; c<1000; n+=2) {
if (n < sum_proper_divisors(n)) {
c++
}
}
printf(fmt,1000,n-2... | using static System.Console;
using System.Collections.Generic;
using System.Linq;
public static class AbundantOddNumbers
{
public static void Main() {
WriteLine("First 25 abundant odd numbers:");
foreach (var x in AbundantNumbers().Take(25)) WriteLine(x.Format());
WriteLine();
Write... |
Convert this AWK block to C#, preserving its control flow and logic. |
BEGIN {
print(" index number sum")
fmt = "%8s %10d %10d\n"
n = 1
for (c=0; c<25; n+=2) {
if (n < sum_proper_divisors(n)) {
printf(fmt,++c,n,sum)
}
}
for (; c<1000; n+=2) {
if (n < sum_proper_divisors(n)) {
c++
}
}
printf(fmt,1000,n-2... | using static System.Console;
using System.Collections.Generic;
using System.Linq;
public static class AbundantOddNumbers
{
public static void Main() {
WriteLine("First 25 abundant odd numbers:");
foreach (var x in AbundantNumbers().Take(25)) WriteLine(x.Format());
WriteLine();
Write... |
Change the programming language of this snippet from AWK to C++ without modifying what it does. |
BEGIN {
print(" index number sum")
fmt = "%8s %10d %10d\n"
n = 1
for (c=0; c<25; n+=2) {
if (n < sum_proper_divisors(n)) {
printf(fmt,++c,n,sum)
}
}
for (; c<1000; n+=2) {
if (n < sum_proper_divisors(n)) {
c++
}
}
printf(fmt,1000,n-2... | #include <algorithm>
#include <iostream>
#include <numeric>
#include <sstream>
#include <vector>
std::vector<int> divisors(int n) {
std::vector<int> divs{ 1 };
std::vector<int> divs2;
for (int i = 2; i*i <= n; i++) {
if (n%i == 0) {
int j = n / i;
divs.push_back(i);
... |
Ensure the translated C++ code behaves exactly like the original AWK snippet. |
BEGIN {
print(" index number sum")
fmt = "%8s %10d %10d\n"
n = 1
for (c=0; c<25; n+=2) {
if (n < sum_proper_divisors(n)) {
printf(fmt,++c,n,sum)
}
}
for (; c<1000; n+=2) {
if (n < sum_proper_divisors(n)) {
c++
}
}
printf(fmt,1000,n-2... | #include <algorithm>
#include <iostream>
#include <numeric>
#include <sstream>
#include <vector>
std::vector<int> divisors(int n) {
std::vector<int> divs{ 1 };
std::vector<int> divs2;
for (int i = 2; i*i <= n; i++) {
if (n%i == 0) {
int j = n / i;
divs.push_back(i);
... |
Produce a language-to-language conversion: from AWK to Java, same semantics. |
BEGIN {
print(" index number sum")
fmt = "%8s %10d %10d\n"
n = 1
for (c=0; c<25; n+=2) {
if (n < sum_proper_divisors(n)) {
printf(fmt,++c,n,sum)
}
}
for (; c<1000; n+=2) {
if (n < sum_proper_divisors(n)) {
c++
}
}
printf(fmt,1000,n-2... | import java.util.ArrayList;
import java.util.List;
public class AbundantOddNumbers {
private static List<Integer> list = new ArrayList<>();
private static List<Integer> result = new ArrayList<>();
public static void main(String[] args) {
System.out.println("First 25: ");
abundantOdd(1,1000... |
Maintain the same structure and functionality when rewriting this code in Java. |
BEGIN {
print(" index number sum")
fmt = "%8s %10d %10d\n"
n = 1
for (c=0; c<25; n+=2) {
if (n < sum_proper_divisors(n)) {
printf(fmt,++c,n,sum)
}
}
for (; c<1000; n+=2) {
if (n < sum_proper_divisors(n)) {
c++
}
}
printf(fmt,1000,n-2... | import java.util.ArrayList;
import java.util.List;
public class AbundantOddNumbers {
private static List<Integer> list = new ArrayList<>();
private static List<Integer> result = new ArrayList<>();
public static void main(String[] args) {
System.out.println("First 25: ");
abundantOdd(1,1000... |
Generate a Python translation of this AWK snippet without changing its computational steps. |
BEGIN {
print(" index number sum")
fmt = "%8s %10d %10d\n"
n = 1
for (c=0; c<25; n+=2) {
if (n < sum_proper_divisors(n)) {
printf(fmt,++c,n,sum)
}
}
for (; c<1000; n+=2) {
if (n < sum_proper_divisors(n)) {
c++
}
}
printf(fmt,1000,n-2... |
oddNumber = 1
aCount = 0
dSum = 0
from math import sqrt
def divisorSum(n):
sum = 1
i = int(sqrt(n)+1)
for d in range (2, i):
if n % d == 0:
sum += d
otherD = n // d
if otherD != d:
sum += otherD
return sum
print ("The first 25 abu... |
Produce a functionally identical Python code for the snippet given in AWK. |
BEGIN {
print(" index number sum")
fmt = "%8s %10d %10d\n"
n = 1
for (c=0; c<25; n+=2) {
if (n < sum_proper_divisors(n)) {
printf(fmt,++c,n,sum)
}
}
for (; c<1000; n+=2) {
if (n < sum_proper_divisors(n)) {
c++
}
}
printf(fmt,1000,n-2... |
oddNumber = 1
aCount = 0
dSum = 0
from math import sqrt
def divisorSum(n):
sum = 1
i = int(sqrt(n)+1)
for d in range (2, i):
if n % d == 0:
sum += d
otherD = n // d
if otherD != d:
sum += otherD
return sum
print ("The first 25 abu... |
Preserve the algorithm and functionality while converting the code from AWK to VB. |
BEGIN {
print(" index number sum")
fmt = "%8s %10d %10d\n"
n = 1
for (c=0; c<25; n+=2) {
if (n < sum_proper_divisors(n)) {
printf(fmt,++c,n,sum)
}
}
for (; c<1000; n+=2) {
if (n < sum_proper_divisors(n)) {
c++
}
}
printf(fmt,1000,n-2... | Module AbundantOddNumbers
Private Function divisorSum(n As Integer) As Integer
Dim sum As Integer = 1
For d As Integer = 2 To Math.Round(Math.Sqrt(n))
If n Mod d = 0 Then
sum += d
Dim otherD As Integer = n \ d
IF otherD... |
Convert the following code from AWK to VB, ensuring the logic remains intact. |
BEGIN {
print(" index number sum")
fmt = "%8s %10d %10d\n"
n = 1
for (c=0; c<25; n+=2) {
if (n < sum_proper_divisors(n)) {
printf(fmt,++c,n,sum)
}
}
for (; c<1000; n+=2) {
if (n < sum_proper_divisors(n)) {
c++
}
}
printf(fmt,1000,n-2... | Module AbundantOddNumbers
Private Function divisorSum(n As Integer) As Integer
Dim sum As Integer = 1
For d As Integer = 2 To Math.Round(Math.Sqrt(n))
If n Mod d = 0 Then
sum += d
Dim otherD As Integer = n \ d
IF otherD... |
Generate a Go translation of this AWK snippet without changing its computational steps. |
BEGIN {
print(" index number sum")
fmt = "%8s %10d %10d\n"
n = 1
for (c=0; c<25; n+=2) {
if (n < sum_proper_divisors(n)) {
printf(fmt,++c,n,sum)
}
}
for (; c<1000; n+=2) {
if (n < sum_proper_divisors(n)) {
c++
}
}
printf(fmt,1000,n-2... | package main
import (
"fmt"
"strconv"
)
func divisors(n int) []int {
divs := []int{1}
divs2 := []int{}
for i := 2; i*i <= n; i++ {
if n%i == 0 {
j := n / i
divs = append(divs, i)
if i != j {
divs2 = append(divs2, j)
}
... |
Convert the following code from AWK to Go, ensuring the logic remains intact. |
BEGIN {
print(" index number sum")
fmt = "%8s %10d %10d\n"
n = 1
for (c=0; c<25; n+=2) {
if (n < sum_proper_divisors(n)) {
printf(fmt,++c,n,sum)
}
}
for (; c<1000; n+=2) {
if (n < sum_proper_divisors(n)) {
c++
}
}
printf(fmt,1000,n-2... | package main
import (
"fmt"
"strconv"
)
func divisors(n int) []int {
divs := []int{1}
divs2 := []int{}
for i := 2; i*i <= n; i++ {
if n%i == 0 {
j := n / i
divs = append(divs, i)
if i != j {
divs2 = append(divs2, j)
}
... |
Port the provided Common_Lisp code into C while preserving the original functionality. |
(eval-when (:compile-toplevel :load-toplevel)
(ql:quickload '("cl-annot" "iterate" "alexandria")))
(defpackage :abundant-numbers
(:use :common-lisp :cl-annot :iterate)
(:import-from :alexandria :butlast))
(in-package :abundant-numbers)
(annot:enable-annot-syntax)
@inline
(defun divisors (n)
"Returns the d... | #include <stdio.h>
#include <math.h>
unsigned sum_proper_divisors(const unsigned n) {
unsigned sum = 1;
for (unsigned i = 3, j; i < sqrt(n)+1; i += 2) if (n % i == 0) sum += i + (i == (j = n / i) ? 0 : j);
return sum;
}
int main(int argc, char const *argv[]) {
unsigned n, c;
for (n = 1, c = 0; c < 25; n +... |
Change the following Common_Lisp code into C without altering its purpose. |
(eval-when (:compile-toplevel :load-toplevel)
(ql:quickload '("cl-annot" "iterate" "alexandria")))
(defpackage :abundant-numbers
(:use :common-lisp :cl-annot :iterate)
(:import-from :alexandria :butlast))
(in-package :abundant-numbers)
(annot:enable-annot-syntax)
@inline
(defun divisors (n)
"Returns the d... | #include <stdio.h>
#include <math.h>
unsigned sum_proper_divisors(const unsigned n) {
unsigned sum = 1;
for (unsigned i = 3, j; i < sqrt(n)+1; i += 2) if (n % i == 0) sum += i + (i == (j = n / i) ? 0 : j);
return sum;
}
int main(int argc, char const *argv[]) {
unsigned n, c;
for (n = 1, c = 0; c < 25; n +... |
Transform the following Common_Lisp implementation into C#, maintaining the same output and logic. |
(eval-when (:compile-toplevel :load-toplevel)
(ql:quickload '("cl-annot" "iterate" "alexandria")))
(defpackage :abundant-numbers
(:use :common-lisp :cl-annot :iterate)
(:import-from :alexandria :butlast))
(in-package :abundant-numbers)
(annot:enable-annot-syntax)
@inline
(defun divisors (n)
"Returns the d... | using static System.Console;
using System.Collections.Generic;
using System.Linq;
public static class AbundantOddNumbers
{
public static void Main() {
WriteLine("First 25 abundant odd numbers:");
foreach (var x in AbundantNumbers().Take(25)) WriteLine(x.Format());
WriteLine();
Write... |
Port the following code from Common_Lisp to C# with equivalent syntax and logic. |
(eval-when (:compile-toplevel :load-toplevel)
(ql:quickload '("cl-annot" "iterate" "alexandria")))
(defpackage :abundant-numbers
(:use :common-lisp :cl-annot :iterate)
(:import-from :alexandria :butlast))
(in-package :abundant-numbers)
(annot:enable-annot-syntax)
@inline
(defun divisors (n)
"Returns the d... | using static System.Console;
using System.Collections.Generic;
using System.Linq;
public static class AbundantOddNumbers
{
public static void Main() {
WriteLine("First 25 abundant odd numbers:");
foreach (var x in AbundantNumbers().Take(25)) WriteLine(x.Format());
WriteLine();
Write... |
Translate this program into C++ but keep the logic exactly as in Common_Lisp. |
(eval-when (:compile-toplevel :load-toplevel)
(ql:quickload '("cl-annot" "iterate" "alexandria")))
(defpackage :abundant-numbers
(:use :common-lisp :cl-annot :iterate)
(:import-from :alexandria :butlast))
(in-package :abundant-numbers)
(annot:enable-annot-syntax)
@inline
(defun divisors (n)
"Returns the d... | #include <algorithm>
#include <iostream>
#include <numeric>
#include <sstream>
#include <vector>
std::vector<int> divisors(int n) {
std::vector<int> divs{ 1 };
std::vector<int> divs2;
for (int i = 2; i*i <= n; i++) {
if (n%i == 0) {
int j = n / i;
divs.push_back(i);
... |
Generate a C++ translation of this Common_Lisp snippet without changing its computational steps. |
(eval-when (:compile-toplevel :load-toplevel)
(ql:quickload '("cl-annot" "iterate" "alexandria")))
(defpackage :abundant-numbers
(:use :common-lisp :cl-annot :iterate)
(:import-from :alexandria :butlast))
(in-package :abundant-numbers)
(annot:enable-annot-syntax)
@inline
(defun divisors (n)
"Returns the d... | #include <algorithm>
#include <iostream>
#include <numeric>
#include <sstream>
#include <vector>
std::vector<int> divisors(int n) {
std::vector<int> divs{ 1 };
std::vector<int> divs2;
for (int i = 2; i*i <= n; i++) {
if (n%i == 0) {
int j = n / i;
divs.push_back(i);
... |
Change the programming language of this snippet from Common_Lisp to Java without modifying what it does. |
(eval-when (:compile-toplevel :load-toplevel)
(ql:quickload '("cl-annot" "iterate" "alexandria")))
(defpackage :abundant-numbers
(:use :common-lisp :cl-annot :iterate)
(:import-from :alexandria :butlast))
(in-package :abundant-numbers)
(annot:enable-annot-syntax)
@inline
(defun divisors (n)
"Returns the d... | import java.util.ArrayList;
import java.util.List;
public class AbundantOddNumbers {
private static List<Integer> list = new ArrayList<>();
private static List<Integer> result = new ArrayList<>();
public static void main(String[] args) {
System.out.println("First 25: ");
abundantOdd(1,1000... |
Can you help me rewrite this code in Java instead of Common_Lisp, keeping it the same logically? |
(eval-when (:compile-toplevel :load-toplevel)
(ql:quickload '("cl-annot" "iterate" "alexandria")))
(defpackage :abundant-numbers
(:use :common-lisp :cl-annot :iterate)
(:import-from :alexandria :butlast))
(in-package :abundant-numbers)
(annot:enable-annot-syntax)
@inline
(defun divisors (n)
"Returns the d... | import java.util.ArrayList;
import java.util.List;
public class AbundantOddNumbers {
private static List<Integer> list = new ArrayList<>();
private static List<Integer> result = new ArrayList<>();
public static void main(String[] args) {
System.out.println("First 25: ");
abundantOdd(1,1000... |
Write a version of this Common_Lisp function in Python with identical behavior. |
(eval-when (:compile-toplevel :load-toplevel)
(ql:quickload '("cl-annot" "iterate" "alexandria")))
(defpackage :abundant-numbers
(:use :common-lisp :cl-annot :iterate)
(:import-from :alexandria :butlast))
(in-package :abundant-numbers)
(annot:enable-annot-syntax)
@inline
(defun divisors (n)
"Returns the d... |
oddNumber = 1
aCount = 0
dSum = 0
from math import sqrt
def divisorSum(n):
sum = 1
i = int(sqrt(n)+1)
for d in range (2, i):
if n % d == 0:
sum += d
otherD = n // d
if otherD != d:
sum += otherD
return sum
print ("The first 25 abu... |
Convert this Common_Lisp snippet to Python and keep its semantics consistent. |
(eval-when (:compile-toplevel :load-toplevel)
(ql:quickload '("cl-annot" "iterate" "alexandria")))
(defpackage :abundant-numbers
(:use :common-lisp :cl-annot :iterate)
(:import-from :alexandria :butlast))
(in-package :abundant-numbers)
(annot:enable-annot-syntax)
@inline
(defun divisors (n)
"Returns the d... |
oddNumber = 1
aCount = 0
dSum = 0
from math import sqrt
def divisorSum(n):
sum = 1
i = int(sqrt(n)+1)
for d in range (2, i):
if n % d == 0:
sum += d
otherD = n // d
if otherD != d:
sum += otherD
return sum
print ("The first 25 abu... |
Convert the following code from Common_Lisp to VB, ensuring the logic remains intact. |
(eval-when (:compile-toplevel :load-toplevel)
(ql:quickload '("cl-annot" "iterate" "alexandria")))
(defpackage :abundant-numbers
(:use :common-lisp :cl-annot :iterate)
(:import-from :alexandria :butlast))
(in-package :abundant-numbers)
(annot:enable-annot-syntax)
@inline
(defun divisors (n)
"Returns the d... | Module AbundantOddNumbers
Private Function divisorSum(n As Integer) As Integer
Dim sum As Integer = 1
For d As Integer = 2 To Math.Round(Math.Sqrt(n))
If n Mod d = 0 Then
sum += d
Dim otherD As Integer = n \ d
IF otherD... |
Write the same code in VB as shown below in Common_Lisp. |
(eval-when (:compile-toplevel :load-toplevel)
(ql:quickload '("cl-annot" "iterate" "alexandria")))
(defpackage :abundant-numbers
(:use :common-lisp :cl-annot :iterate)
(:import-from :alexandria :butlast))
(in-package :abundant-numbers)
(annot:enable-annot-syntax)
@inline
(defun divisors (n)
"Returns the d... | Module AbundantOddNumbers
Private Function divisorSum(n As Integer) As Integer
Dim sum As Integer = 1
For d As Integer = 2 To Math.Round(Math.Sqrt(n))
If n Mod d = 0 Then
sum += d
Dim otherD As Integer = n \ d
IF otherD... |
Write the same algorithm in Go as shown in this Common_Lisp implementation. |
(eval-when (:compile-toplevel :load-toplevel)
(ql:quickload '("cl-annot" "iterate" "alexandria")))
(defpackage :abundant-numbers
(:use :common-lisp :cl-annot :iterate)
(:import-from :alexandria :butlast))
(in-package :abundant-numbers)
(annot:enable-annot-syntax)
@inline
(defun divisors (n)
"Returns the d... | package main
import (
"fmt"
"strconv"
)
func divisors(n int) []int {
divs := []int{1}
divs2 := []int{}
for i := 2; i*i <= n; i++ {
if n%i == 0 {
j := n / i
divs = append(divs, i)
if i != j {
divs2 = append(divs2, j)
}
... |
Produce a language-to-language conversion: from Common_Lisp to Go, same semantics. |
(eval-when (:compile-toplevel :load-toplevel)
(ql:quickload '("cl-annot" "iterate" "alexandria")))
(defpackage :abundant-numbers
(:use :common-lisp :cl-annot :iterate)
(:import-from :alexandria :butlast))
(in-package :abundant-numbers)
(annot:enable-annot-syntax)
@inline
(defun divisors (n)
"Returns the d... | package main
import (
"fmt"
"strconv"
)
func divisors(n int) []int {
divs := []int{1}
divs2 := []int{}
for i := 2; i*i <= n; i++ {
if n%i == 0 {
j := n / i
divs = append(divs, i)
if i != j {
divs2 = append(divs2, j)
}
... |
Translate the given D code snippet into C without altering its behavior. | import std.stdio;
int[] divisors(int n) {
import std.range;
int[] divs = [1];
int[] divs2;
for (int i = 2; i * i <= n; i++) {
if (n % i == 0) {
int j = n / i;
divs ~= i;
if (i != j) {
divs2 ~= j;
}
}
}
divs ~= ret... | #include <stdio.h>
#include <math.h>
unsigned sum_proper_divisors(const unsigned n) {
unsigned sum = 1;
for (unsigned i = 3, j; i < sqrt(n)+1; i += 2) if (n % i == 0) sum += i + (i == (j = n / i) ? 0 : j);
return sum;
}
int main(int argc, char const *argv[]) {
unsigned n, c;
for (n = 1, c = 0; c < 25; n +... |
Generate a C translation of this D snippet without changing its computational steps. | import std.stdio;
int[] divisors(int n) {
import std.range;
int[] divs = [1];
int[] divs2;
for (int i = 2; i * i <= n; i++) {
if (n % i == 0) {
int j = n / i;
divs ~= i;
if (i != j) {
divs2 ~= j;
}
}
}
divs ~= ret... | #include <stdio.h>
#include <math.h>
unsigned sum_proper_divisors(const unsigned n) {
unsigned sum = 1;
for (unsigned i = 3, j; i < sqrt(n)+1; i += 2) if (n % i == 0) sum += i + (i == (j = n / i) ? 0 : j);
return sum;
}
int main(int argc, char const *argv[]) {
unsigned n, c;
for (n = 1, c = 0; c < 25; n +... |
Transform the following D implementation into C#, maintaining the same output and logic. | import std.stdio;
int[] divisors(int n) {
import std.range;
int[] divs = [1];
int[] divs2;
for (int i = 2; i * i <= n; i++) {
if (n % i == 0) {
int j = n / i;
divs ~= i;
if (i != j) {
divs2 ~= j;
}
}
}
divs ~= ret... | using static System.Console;
using System.Collections.Generic;
using System.Linq;
public static class AbundantOddNumbers
{
public static void Main() {
WriteLine("First 25 abundant odd numbers:");
foreach (var x in AbundantNumbers().Take(25)) WriteLine(x.Format());
WriteLine();
Write... |
Convert this D block to C#, preserving its control flow and logic. | import std.stdio;
int[] divisors(int n) {
import std.range;
int[] divs = [1];
int[] divs2;
for (int i = 2; i * i <= n; i++) {
if (n % i == 0) {
int j = n / i;
divs ~= i;
if (i != j) {
divs2 ~= j;
}
}
}
divs ~= ret... | using static System.Console;
using System.Collections.Generic;
using System.Linq;
public static class AbundantOddNumbers
{
public static void Main() {
WriteLine("First 25 abundant odd numbers:");
foreach (var x in AbundantNumbers().Take(25)) WriteLine(x.Format());
WriteLine();
Write... |
Produce a functionally identical C++ code for the snippet given in D. | import std.stdio;
int[] divisors(int n) {
import std.range;
int[] divs = [1];
int[] divs2;
for (int i = 2; i * i <= n; i++) {
if (n % i == 0) {
int j = n / i;
divs ~= i;
if (i != j) {
divs2 ~= j;
}
}
}
divs ~= ret... | #include <algorithm>
#include <iostream>
#include <numeric>
#include <sstream>
#include <vector>
std::vector<int> divisors(int n) {
std::vector<int> divs{ 1 };
std::vector<int> divs2;
for (int i = 2; i*i <= n; i++) {
if (n%i == 0) {
int j = n / i;
divs.push_back(i);
... |
Convert this D block to C++, preserving its control flow and logic. | import std.stdio;
int[] divisors(int n) {
import std.range;
int[] divs = [1];
int[] divs2;
for (int i = 2; i * i <= n; i++) {
if (n % i == 0) {
int j = n / i;
divs ~= i;
if (i != j) {
divs2 ~= j;
}
}
}
divs ~= ret... | #include <algorithm>
#include <iostream>
#include <numeric>
#include <sstream>
#include <vector>
std::vector<int> divisors(int n) {
std::vector<int> divs{ 1 };
std::vector<int> divs2;
for (int i = 2; i*i <= n; i++) {
if (n%i == 0) {
int j = n / i;
divs.push_back(i);
... |
Translate the given D code snippet into Java without altering its behavior. | import std.stdio;
int[] divisors(int n) {
import std.range;
int[] divs = [1];
int[] divs2;
for (int i = 2; i * i <= n; i++) {
if (n % i == 0) {
int j = n / i;
divs ~= i;
if (i != j) {
divs2 ~= j;
}
}
}
divs ~= ret... | import java.util.ArrayList;
import java.util.List;
public class AbundantOddNumbers {
private static List<Integer> list = new ArrayList<>();
private static List<Integer> result = new ArrayList<>();
public static void main(String[] args) {
System.out.println("First 25: ");
abundantOdd(1,1000... |
Port the following code from D to Java with equivalent syntax and logic. | import std.stdio;
int[] divisors(int n) {
import std.range;
int[] divs = [1];
int[] divs2;
for (int i = 2; i * i <= n; i++) {
if (n % i == 0) {
int j = n / i;
divs ~= i;
if (i != j) {
divs2 ~= j;
}
}
}
divs ~= ret... | import java.util.ArrayList;
import java.util.List;
public class AbundantOddNumbers {
private static List<Integer> list = new ArrayList<>();
private static List<Integer> result = new ArrayList<>();
public static void main(String[] args) {
System.out.println("First 25: ");
abundantOdd(1,1000... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.