kazuyamaa/multi-language-messages-01 huggingface dataset:
Task: Fibonacci sequence
C: 
fun fibb
    loop
        a = funparam[0]
        break (a < 2)

        a--

        
        a -> stack

        
        funparam[0] = a
        call fibb

        
        b = funparam[0]
        stack -> a

        
        b -> stack

        a--

        
        funparam[0] = a
        call fibb

        
        c = funparam[0]
        stack -> b

        
        b += c
        a = b

        funparam[0] = a

        break
    end
end



VB: Public Function Fib(ByVal n As Integer) As Variant
    Dim fib0 As Variant, fib1 As Variant, sum As Variant
    Dim i As Integer
    fib0 = 0
    fib1 = 1
    For i = 1 To n
        sum = fib0 + fib1
        fib0 = fib1
        fib1 = sum
    Next i
    Fib = fib0
End Function
Task: Fibonacci sequence
C#: public static ulong Fib(uint n) {
    return (n < 2)? n : Fib(n - 1) + Fib(n - 2);
}

C++: #include <iostream>

int main()
{
        unsigned int a = 1, b = 1;
        unsigned int target = 48;
        for(unsigned int n = 3; n <= target; ++n)
        {
                unsigned int fib = a + b;
                std::cout << "F("<< n << ") = " << fib << std::endl;
                a = b;
                b = fib;
        }

        return 0;
}
Task: Fibonacci sequence
C++: #include <iostream>

int main()
{
        unsigned int a = 1, b = 1;
        unsigned int target = 48;
        for(unsigned int n = 3; n <= target; ++n)
        {
                unsigned int fib = a + b;
                std::cout << "F("<< n << ") = " << fib << std::endl;
                a = b;
                b = fib;
        }

        return 0;
}

Go: func fib(a int) int {
  if a < 2 {
    return a
  }
  return fib(a - 1) + fib(a - 2)
}
Task: Fibonacci sequence
C++: #include <iostream>

int main()
{
        unsigned int a = 1, b = 1;
        unsigned int target = 48;
        for(unsigned int n = 3; n <= target; ++n)
        {
                unsigned int fib = a + b;
                std::cout << "F("<< n << ") = " << fib << std::endl;
                a = b;
                b = fib;
        }

        return 0;
}

Java: public static long itFibN(int n)
{
 if (n < 2)
  return n;
 long ans = 0;
 long n1 = 0;
 long n2 = 1;
 for(n--; n > 0; n--)
 {
  ans = n1 + n2;
  n1 = n2;
  n2 = ans;
 }
 return ans;
}
Task: Fibonacci sequence
C++: #include <iostream>

int main()
{
        unsigned int a = 1, b = 1;
        unsigned int target = 48;
        for(unsigned int n = 3; n <= target; ++n)
        {
                unsigned int fib = a + b;
                std::cout << "F("<< n << ") = " << fib << std::endl;
                a = b;
                b = fib;
        }

        return 0;
}

Python: from math import *

def analytic_fibonacci(n):
  sqrt_5 = sqrt(5);
  p = (1 + sqrt_5) / 2;
  q = 1/p;
  return int( (p**n + q**n) / sqrt_5 + 0.5 )

for i in range(1,31):
  print analytic_fibonacci(i),
Task: Fibonacci sequence
C++: #include <iostream>

int main()
{
        unsigned int a = 1, b = 1;
        unsigned int target = 48;
        for(unsigned int n = 3; n <= target; ++n)
        {
                unsigned int fib = a + b;
                std::cout << "F("<< n << ") = " << fib << std::endl;
                a = b;
                b = fib;
        }

        return 0;
}

VB: Public Function Fib(ByVal n As Integer) As Variant
    Dim fib0 As Variant, fib1 As Variant, sum As Variant
    Dim i As Integer
    fib0 = 0
    fib1 = 1
    For i = 1 To n
        sum = fib0 + fib1
        fib0 = fib1
        fib1 = sum
    Next i
    Fib = fib0
End Function
Task: Fibonacci sequence
C#: public static ulong Fib(uint n) {
    return (n < 2)? n : Fib(n - 1) + Fib(n - 2);
}

Go: func fib(a int) int {
  if a < 2 {
    return a
  }
  return fib(a - 1) + fib(a - 2)
}
Task: Fibonacci sequence
C#: public static ulong Fib(uint n) {
    return (n < 2)? n : Fib(n - 1) + Fib(n - 2);
}

VB: Public Function Fib(ByVal n As Integer) As Variant
    Dim fib0 As Variant, fib1 As Variant, sum As Variant
    Dim i As Integer
    fib0 = 0
    fib1 = 1
    For i = 1 To n
        sum = fib0 + fib1
        fib0 = fib1
        fib1 = sum
    Next i
    Fib = fib0
End Function
Task: Fibonacci sequence
Java: public static long itFibN(int n)
{
 if (n < 2)
  return n;
 long ans = 0;
 long n1 = 0;
 long n2 = 1;
 for(n--; n > 0; n--)
 {
  ans = n1 + n2;
  n1 = n2;
  n2 = ans;
 }
 return ans;
}

Python: from math import *

def analytic_fibonacci(n):
  sqrt_5 = sqrt(5);
  p = (1 + sqrt_5) / 2;
  q = 1/p;
  return int( (p**n + q**n) / sqrt_5 + 0.5 )

for i in range(1,31):
  print analytic_fibonacci(i),
Task: Fibonacci sequence
Java: public static long itFibN(int n)
{
 if (n < 2)
  return n;
 long ans = 0;
 long n1 = 0;
 long n2 = 1;
 for(n--; n > 0; n--)
 {
  ans = n1 + n2;
  n1 = n2;
  n2 = ans;
 }
 return ans;
}

VB: Public Function Fib(ByVal n As Integer) As Variant
    Dim fib0 As Variant, fib1 As Variant, sum As Variant
    Dim i As Integer
    fib0 = 0
    fib1 = 1
    For i = 1 To n
        sum = fib0 + fib1
        fib0 = fib1
        fib1 = sum
    Next i
    Fib = fib0
End Function
Task: Fibonacci sequence
C#: public static ulong Fib(uint n) {
    return (n < 2)? n : Fib(n - 1) + Fib(n - 2);
}

Java: public static long itFibN(int n)
{
 if (n < 2)
  return n;
 long ans = 0;
 long n1 = 0;
 long n2 = 1;
 for(n--; n > 0; n--)
 {
  ans = n1 + n2;
  n1 = n2;
  n2 = ans;
 }
 return ans;
}
Task: Fibonacci sequence
C#: public static ulong Fib(uint n) {
    return (n < 2)? n : Fib(n - 1) + Fib(n - 2);
}

Python: from math import *

def analytic_fibonacci(n):
  sqrt_5 = sqrt(5);
  p = (1 + sqrt_5) / 2;
  q = 1/p;
  return int( (p**n + q**n) / sqrt_5 + 0.5 )

for i in range(1,31):
  print analytic_fibonacci(i),
Task: Fibonacci sequence
Go: func fib(a int) int {
  if a < 2 {
    return a
  }
  return fib(a - 1) + fib(a - 2)
}

Java: public static long itFibN(int n)
{
 if (n < 2)
  return n;
 long ans = 0;
 long n1 = 0;
 long n2 = 1;
 for(n--; n > 0; n--)
 {
  ans = n1 + n2;
  n1 = n2;
  n2 = ans;
 }
 return ans;
}
Task: Fibonacci sequence
Python: from math import *

def analytic_fibonacci(n):
  sqrt_5 = sqrt(5);
  p = (1 + sqrt_5) / 2;
  q = 1/p;
  return int( (p**n + q**n) / sqrt_5 + 0.5 )

for i in range(1,31):
  print analytic_fibonacci(i),

VB: Public Function Fib(ByVal n As Integer) As Variant
    Dim fib0 As Variant, fib1 As Variant, sum As Variant
    Dim i As Integer
    fib0 = 0
    fib1 = 1
    For i = 1 To n
        sum = fib0 + fib1
        fib0 = fib1
        fib1 = sum
    Next i
    Fib = fib0
End Function
Task: Fibonacci sequence
Go: func fib(a int) int {
  if a < 2 {
    return a
  }
  return fib(a - 1) + fib(a - 2)
}

Python: from math import *

def analytic_fibonacci(n):
  sqrt_5 = sqrt(5);
  p = (1 + sqrt_5) / 2;
  q = 1/p;
  return int( (p**n + q**n) / sqrt_5 + 0.5 )

for i in range(1,31):
  print analytic_fibonacci(i),
Task: Fibonacci sequence
Go: func fib(a int) int {
  if a < 2 {
    return a
  }
  return fib(a - 1) + fib(a - 2)
}

VB: Public Function Fib(ByVal n As Integer) As Variant
    Dim fib0 As Variant, fib1 As Variant, sum As Variant
    Dim i As Integer
    fib0 = 0
    fib1 = 1
    For i = 1 To n
        sum = fib0 + fib1
        fib0 = fib1
        fib1 = sum
    Next i
    Fib = fib0
End Function
Task: Fibonacci sequence
C: 
fun fibb
    loop
        a = funparam[0]
        break (a < 2)

        a--

        
        a -> stack

        
        funparam[0] = a
        call fibb

        
        b = funparam[0]
        stack -> a

        
        b -> stack

        a--

        
        funparam[0] = a
        call fibb

        
        c = funparam[0]
        stack -> b

        
        b += c
        a = b

        funparam[0] = a

        break
    end
end



PHP: function fibIter($n) {
    if ($n < 2) {
        return $n;
    }
    $fibPrev = 0;
    $fib = 1;
    foreach (range(1, $n-1) as $i) {
        list($fibPrev, $fib) = array($fib, $fib + $fibPrev);
    }
    return $fib;
}
Task: Fibonacci sequence
C#: public static ulong Fib(uint n) {
    return (n < 2)? n : Fib(n - 1) + Fib(n - 2);
}

PHP: function fibIter($n) {
    if ($n < 2) {
        return $n;
    }
    $fibPrev = 0;
    $fib = 1;
    foreach (range(1, $n-1) as $i) {
        list($fibPrev, $fib) = array($fib, $fib + $fibPrev);
    }
    return $fib;
}
Task: Fibonacci sequence
C++: #include <iostream>

int main()
{
        unsigned int a = 1, b = 1;
        unsigned int target = 48;
        for(unsigned int n = 3; n <= target; ++n)
        {
                unsigned int fib = a + b;
                std::cout << "F("<< n << ") = " << fib << std::endl;
                a = b;
                b = fib;
        }

        return 0;
}

PHP: function fibIter($n) {
    if ($n < 2) {
        return $n;
    }
    $fibPrev = 0;
    $fib = 1;
    foreach (range(1, $n-1) as $i) {
        list($fibPrev, $fib) = array($fib, $fib + $fibPrev);
    }
    return $fib;
}
Task: Fibonacci sequence
Go: func fib(a int) int {
  if a < 2 {
    return a
  }
  return fib(a - 1) + fib(a - 2)
}

PHP: function fibIter($n) {
    if ($n < 2) {
        return $n;
    }
    $fibPrev = 0;
    $fib = 1;
    foreach (range(1, $n-1) as $i) {
        list($fibPrev, $fib) = array($fib, $fib + $fibPrev);
    }
    return $fib;
}
Task: Fibonacci sequence
Java: public static long itFibN(int n)
{
 if (n < 2)
  return n;
 long ans = 0;
 long n1 = 0;
 long n2 = 1;
 for(n--; n > 0; n--)
 {
  ans = n1 + n2;
  n1 = n2;
  n2 = ans;
 }
 return ans;
}

PHP: function fibIter($n) {
    if ($n < 2) {
        return $n;
    }
    $fibPrev = 0;
    $fib = 1;
    foreach (range(1, $n-1) as $i) {
        list($fibPrev, $fib) = array($fib, $fib + $fibPrev);
    }
    return $fib;
}
Task: Fibonacci sequence
Python: from math import *

def analytic_fibonacci(n):
  sqrt_5 = sqrt(5);
  p = (1 + sqrt_5) / 2;
  q = 1/p;
  return int( (p**n + q**n) / sqrt_5 + 0.5 )

for i in range(1,31):
  print analytic_fibonacci(i),

PHP: function fibIter($n) {
    if ($n < 2) {
        return $n;
    }
    $fibPrev = 0;
    $fib = 1;
    foreach (range(1, $n-1) as $i) {
        list($fibPrev, $fib) = array($fib, $fib + $fibPrev);
    }
    return $fib;
}
Task: Fibonacci sequence
VB: Public Function Fib(ByVal n As Integer) As Variant
    Dim fib0 As Variant, fib1 As Variant, sum As Variant
    Dim i As Integer
    fib0 = 0
    fib1 = 1
    For i = 1 To n
        sum = fib0 + fib1
        fib0 = fib1
        fib1 = sum
    Next i
    Fib = fib0
End Function

PHP: function fibIter($n) {
    if ($n < 2) {
        return $n;
    }
    $fibPrev = 0;
    $fib = 1;
    foreach (range(1, $n-1) as $i) {
        list($fibPrev, $fib) = array($fib, $fib + $fibPrev);
    }
    return $fib;
}
Task: Loops_While
C: int i = 1024;
while(i > 0) {
  printf("%d\n", i);
  i /= 2;
}

C#: int i = 1024;
while(i > 0){
   System.Console.WriteLine(i);
   i /= 2;
}
Task: Loops_While
C: int i = 1024;
while(i > 0) {
  printf("%d\n", i);
  i /= 2;
}

C++: int i = 1024;
while(i > 0){
  std::cout << i << std::endl;
  i /= 2;
}
Task: Loops_While
C: int i = 1024;
while(i > 0) {
  printf("%d\n", i);
  i /= 2;
}

Go: i := 1024
for i > 0 {
  fmt.Printf("%d\n", i)
  i /= 2
}
Task: Loops_While
C: int i = 1024;
while(i > 0) {
  printf("%d\n", i);
  i /= 2;
}

VB: Public Sub LoopsWhile()
    Dim value As Integer
    value = 1024
    Do While value > 0
        Debug.Print value
        value = value / 2
    Loop
End Sub
Task: Loops_While
C#: int i = 1024;
while(i > 0){
   System.Console.WriteLine(i);
   i /= 2;
}

C++: int i = 1024;
while(i > 0){
  std::cout << i << std::endl;
  i /= 2;
}
Task: Loops_While
C++: int i = 1024;
while(i > 0){
  std::cout << i << std::endl;
  i /= 2;
}

Go: i := 1024
for i > 0 {
  fmt.Printf("%d\n", i)
  i /= 2
}
Task: Loops_While
C++: int i = 1024;
while(i > 0){
  std::cout << i << std::endl;
  i /= 2;
}

Java: int i = 1024;
while(i > 0){
   System.out.println(i);
   i >>= 1; 
}
Task: Loops_While
C++: int i = 1024;
while(i > 0){
  std::cout << i << std::endl;
  i /= 2;
}

Python: n = 1024
while n > 0:
    print n
    n //= 2
Task: Loops_While
C++: int i = 1024;
while(i > 0){
  std::cout << i << std::endl;
  i /= 2;
}

VB: Public Sub LoopsWhile()
    Dim value As Integer
    value = 1024
    Do While value > 0
        Debug.Print value
        value = value / 2
    Loop
End Sub
Task: Loops_While
C#: int i = 1024;
while(i > 0){
   System.Console.WriteLine(i);
   i /= 2;
}

Go: i := 1024
for i > 0 {
  fmt.Printf("%d\n", i)
  i /= 2
}
Task: Loops_While
C#: int i = 1024;
while(i > 0){
   System.Console.WriteLine(i);
   i /= 2;
}

Java: int i = 1024;
while(i > 0){
   System.out.println(i);
   i >>= 1; 
}
Task: Loops_While
C#: int i = 1024;
while(i > 0){
   System.Console.WriteLine(i);
   i /= 2;
}

VB: Public Sub LoopsWhile()
    Dim value As Integer
    value = 1024
    Do While value > 0
        Debug.Print value
        value = value / 2
    Loop
End Sub
Task: Loops_While
Go: i := 1024
for i > 0 {
  fmt.Printf("%d\n", i)
  i /= 2
}

Python: n = 1024
while n > 0:
    print n
    n //= 2
Task: Loops_While
Go: i := 1024
for i > 0 {
  fmt.Printf("%d\n", i)
  i /= 2
}

VB: Public Sub LoopsWhile()
    Dim value As Integer
    value = 1024
    Do While value > 0
        Debug.Print value
        value = value / 2
    Loop
End Sub
Task: Loops_While
Python: n = 1024
while n > 0:
    print n
    n //= 2

VB: Public Sub LoopsWhile()
    Dim value As Integer
    value = 1024
    Do While value > 0
        Debug.Print value
        value = value / 2
    Loop
End Sub
Task: Loops_While
Go: i := 1024
for i > 0 {
  fmt.Printf("%d\n", i)
  i /= 2
}

Java: int i = 1024;
while(i > 0){
   System.out.println(i);
   i >>= 1; 
}
Task: Loops_While
Java: int i = 1024;
while(i > 0){
   System.out.println(i);
   i >>= 1; 
}

Python: n = 1024
while n > 0:
    print n
    n //= 2
Task: Loops_While
Java: int i = 1024;
while(i > 0){
   System.out.println(i);
   i >>= 1; 
}

VB: Public Sub LoopsWhile()
    Dim value As Integer
    value = 1024
    Do While value > 0
        Debug.Print value
        value = value / 2
    Loop
End Sub
Task: Loops_While
C: int i = 1024;
while(i > 0) {
  printf("%d\n", i);
  i /= 2;
}

Java: int i = 1024;
while(i > 0){
   System.out.println(i);
   i >>= 1; 
}
Task: Loops_While
C: int i = 1024;
while(i > 0) {
  printf("%d\n", i);
  i /= 2;
}

Python: n = 1024
while n > 0:
    print n
    n //= 2
Task: Loops_While
C#: int i = 1024;
while(i > 0){
   System.Console.WriteLine(i);
   i /= 2;
}

Python: n = 1024
while n > 0:
    print n
    n //= 2
Task: Loops_While
C: int i = 1024;
while(i > 0) {
  printf("%d\n", i);
  i /= 2;
}

PHP: $i = 1024;
while ($i > 0) {
   echo "$i\n";
   $i >>= 1;
}
Task: Loops_While
C#: int i = 1024;
while(i > 0){
   System.Console.WriteLine(i);
   i /= 2;
}

PHP: $i = 1024;
while ($i > 0) {
   echo "$i\n";
   $i >>= 1;
}
Task: Loops_While
C++: int i = 1024;
while(i > 0){
  std::cout << i << std::endl;
  i /= 2;
}

PHP: $i = 1024;
while ($i > 0) {
   echo "$i\n";
   $i >>= 1;
}
Task: Loops_While
Go: i := 1024
for i > 0 {
  fmt.Printf("%d\n", i)
  i /= 2
}

PHP: $i = 1024;
while ($i > 0) {
   echo "$i\n";
   $i >>= 1;
}
Task: Loops_While
Java: int i = 1024;
while(i > 0){
   System.out.println(i);
   i >>= 1; 
}

PHP: $i = 1024;
while ($i > 0) {
   echo "$i\n";
   $i >>= 1;
}
Task: Loops_While
Python: n = 1024
while n > 0:
    print n
    n //= 2

PHP: $i = 1024;
while ($i > 0) {
   echo "$i\n";
   $i >>= 1;
}
Task: Loops_While
VB: Public Sub LoopsWhile()
    Dim value As Integer
    value = 1024
    Do While value > 0
        Debug.Print value
        value = value / 2
    Loop
End Sub

PHP: $i = 1024;
while ($i > 0) {
   echo "$i\n";
   $i >>= 1;
}
Task: Sum of a series
C: #include <stdio.h>

double Invsqr(double n)
{
	return 1 / (n*n);
}

int main (int argc, char *argv[])
{
	int i, start = 1, end = 1000;
	double sum = 0.0;
	
	for( i = start; i <= end; i++)
		sum += Invsqr((double)i);           
	
	printf("%16.14f\n", sum);
	
	return 0;
}

C#: class Program
{
    static void Main(string[] args)
    {
        

        List<double> myList = new List<double>();
        for (double i = 1; i < 1001; i++)
        {
            myList.Add(i);
        }
        

        var sum = myList.Sum(x => 1/(x*x));

        Console.WriteLine(sum);
        Console.ReadLine();
    }
}
Task: Sum of a series
C: #include <stdio.h>

double Invsqr(double n)
{
	return 1 / (n*n);
}

int main (int argc, char *argv[])
{
	int i, start = 1, end = 1000;
	double sum = 0.0;
	
	for( i = start; i <= end; i++)
		sum += Invsqr((double)i);           
	
	printf("%16.14f\n", sum);
	
	return 0;
}

C++: #include <iostream>

double f(double x);

int main()
{
    unsigned int start = 1;
    unsigned int end = 1000;
    double sum = 0;

    for( unsigned int x = start; x <= end; ++x )
    {
        sum += f(x);
    }
    std::cout << "Sum of f(x) from " << start << " to " << end << " is " << sum << std::endl;
    return 0;
}


double f(double x)
{
    return ( 1.0 / ( x * x ) );
}
Task: Sum of a series
C: #include <stdio.h>

double Invsqr(double n)
{
	return 1 / (n*n);
}

int main (int argc, char *argv[])
{
	int i, start = 1, end = 1000;
	double sum = 0.0;
	
	for( i = start; i <= end; i++)
		sum += Invsqr((double)i);           
	
	printf("%16.14f\n", sum);
	
	return 0;
}

Java: public class Sum{
    public static double f(double x){
       return 1/(x*x);
    }
 
    public static void main(String[] args){
       double start = 1;
       double end = 1000;
       double sum = 0;
 
       for(double x = start;x <= end;x++) sum += f(x);
 
       System.out.println("Sum of f(x) from " + start + " to " + end +" is " + sum);
    }
}
Task: Sum of a series
C: #include <stdio.h>

double Invsqr(double n)
{
	return 1 / (n*n);
}

int main (int argc, char *argv[])
{
	int i, start = 1, end = 1000;
	double sum = 0.0;
	
	for( i = start; i <= end; i++)
		sum += Invsqr((double)i);           
	
	printf("%16.14f\n", sum);
	
	return 0;
}

Python: print ( sum(1.0 / (x * x) for x in range(1, 1001)) )
Task: Sum of a series
C: #include <stdio.h>

double Invsqr(double n)
{
	return 1 / (n*n);
}

int main (int argc, char *argv[])
{
	int i, start = 1, end = 1000;
	double sum = 0.0;
	
	for( i = start; i <= end; i++)
		sum += Invsqr((double)i);           
	
	printf("%16.14f\n", sum);
	
	return 0;
}

VB: Private Function sumto(n As Integer) As Double
    Dim res As Double
    For i = 1 To n
        res = res + 1 / i ^ 2
    Next i
    sumto = res
End Function
Public Sub main()
    Debug.Print sumto(1000)
End Sub
Task: Sum of a series
C#: class Program
{
    static void Main(string[] args)
    {
        

        List<double> myList = new List<double>();
        for (double i = 1; i < 1001; i++)
        {
            myList.Add(i);
        }
        

        var sum = myList.Sum(x => 1/(x*x));

        Console.WriteLine(sum);
        Console.ReadLine();
    }
}

C++: #include <iostream>

double f(double x);

int main()
{
    unsigned int start = 1;
    unsigned int end = 1000;
    double sum = 0;

    for( unsigned int x = start; x <= end; ++x )
    {
        sum += f(x);
    }
    std::cout << "Sum of f(x) from " << start << " to " << end << " is " << sum << std::endl;
    return 0;
}


double f(double x)
{
    return ( 1.0 / ( x * x ) );
}
Task: Sum of a series
C++: #include <iostream>

double f(double x);

int main()
{
    unsigned int start = 1;
    unsigned int end = 1000;
    double sum = 0;

    for( unsigned int x = start; x <= end; ++x )
    {
        sum += f(x);
    }
    std::cout << "Sum of f(x) from " << start << " to " << end << " is " << sum << std::endl;
    return 0;
}


double f(double x)
{
    return ( 1.0 / ( x * x ) );
}

Go: package main

import ("fmt"; "math")

func main() {
    fmt.Println("known:   ", math.Pi*math.Pi/6)
    sum := 0.
    for i := 1e3; i > 0; i-- {
        sum += 1 / (i * i)
    }
    fmt.Println("computed:", sum)
}
Task: Sum of a series
C++: #include <iostream>

double f(double x);

int main()
{
    unsigned int start = 1;
    unsigned int end = 1000;
    double sum = 0;

    for( unsigned int x = start; x <= end; ++x )
    {
        sum += f(x);
    }
    std::cout << "Sum of f(x) from " << start << " to " << end << " is " << sum << std::endl;
    return 0;
}


double f(double x)
{
    return ( 1.0 / ( x * x ) );
}

Java: public class Sum{
    public static double f(double x){
       return 1/(x*x);
    }
 
    public static void main(String[] args){
       double start = 1;
       double end = 1000;
       double sum = 0;
 
       for(double x = start;x <= end;x++) sum += f(x);
 
       System.out.println("Sum of f(x) from " + start + " to " + end +" is " + sum);
    }
}
Task: Sum of a series
C++: #include <iostream>

double f(double x);

int main()
{
    unsigned int start = 1;
    unsigned int end = 1000;
    double sum = 0;

    for( unsigned int x = start; x <= end; ++x )
    {
        sum += f(x);
    }
    std::cout << "Sum of f(x) from " << start << " to " << end << " is " << sum << std::endl;
    return 0;
}


double f(double x)
{
    return ( 1.0 / ( x * x ) );
}

Python: print ( sum(1.0 / (x * x) for x in range(1, 1001)) )
Task: Sum of a series
C++: #include <iostream>

double f(double x);

int main()
{
    unsigned int start = 1;
    unsigned int end = 1000;
    double sum = 0;

    for( unsigned int x = start; x <= end; ++x )
    {
        sum += f(x);
    }
    std::cout << "Sum of f(x) from " << start << " to " << end << " is " << sum << std::endl;
    return 0;
}


double f(double x)
{
    return ( 1.0 / ( x * x ) );
}

VB: Private Function sumto(n As Integer) As Double
    Dim res As Double
    For i = 1 To n
        res = res + 1 / i ^ 2
    Next i
    sumto = res
End Function
Public Sub main()
    Debug.Print sumto(1000)
End Sub
Task: Sum of a series
C#: class Program
{
    static void Main(string[] args)
    {
        

        List<double> myList = new List<double>();
        for (double i = 1; i < 1001; i++)
        {
            myList.Add(i);
        }
        

        var sum = myList.Sum(x => 1/(x*x));

        Console.WriteLine(sum);
        Console.ReadLine();
    }
}

Java: public class Sum{
    public static double f(double x){
       return 1/(x*x);
    }
 
    public static void main(String[] args){
       double start = 1;
       double end = 1000;
       double sum = 0;
 
       for(double x = start;x <= end;x++) sum += f(x);
 
       System.out.println("Sum of f(x) from " + start + " to " + end +" is " + sum);
    }
}
Task: Sum of a series
C#: class Program
{
    static void Main(string[] args)
    {
        

        List<double> myList = new List<double>();
        for (double i = 1; i < 1001; i++)
        {
            myList.Add(i);
        }
        

        var sum = myList.Sum(x => 1/(x*x));

        Console.WriteLine(sum);
        Console.ReadLine();
    }
}

VB: Private Function sumto(n As Integer) As Double
    Dim res As Double
    For i = 1 To n
        res = res + 1 / i ^ 2
    Next i
    sumto = res
End Function
Public Sub main()
    Debug.Print sumto(1000)
End Sub
Task: Sum of a series
Java: public class Sum{
    public static double f(double x){
       return 1/(x*x);
    }
 
    public static void main(String[] args){
       double start = 1;
       double end = 1000;
       double sum = 0;
 
       for(double x = start;x <= end;x++) sum += f(x);
 
       System.out.println("Sum of f(x) from " + start + " to " + end +" is " + sum);
    }
}

Python: print ( sum(1.0 / (x * x) for x in range(1, 1001)) )
Task: Sum of a series
Java: public class Sum{
    public static double f(double x){
       return 1/(x*x);
    }
 
    public static void main(String[] args){
       double start = 1;
       double end = 1000;
       double sum = 0;
 
       for(double x = start;x <= end;x++) sum += f(x);
 
       System.out.println("Sum of f(x) from " + start + " to " + end +" is " + sum);
    }
}

VB: Private Function sumto(n As Integer) As Double
    Dim res As Double
    For i = 1 To n
        res = res + 1 / i ^ 2
    Next i
    sumto = res
End Function
Public Sub main()
    Debug.Print sumto(1000)
End Sub
Task: Sum of a series
Go: package main

import ("fmt"; "math")

func main() {
    fmt.Println("known:   ", math.Pi*math.Pi/6)
    sum := 0.
    for i := 1e3; i > 0; i-- {
        sum += 1 / (i * i)
    }
    fmt.Println("computed:", sum)
}

Python: print ( sum(1.0 / (x * x) for x in range(1, 1001)) )