코드 변환하는 프로그램 가지고 노는데 재밌네

뭘로써졌는지 맞춰볼사람?


0. 파이썬 코드

def f (n):
    x = 0.0e0
    for i in range(1, n + 1):
        x = x + i
        cgret = x
    return(cgret)


0. C 코드

double f (int n)
{
  double x;
  int i;
  double cgret;
  x = 0.0e0;
  for (i = 1; i <= n; i++)
  {
    x = x + (double) i;
    cgret = x;
  }
  return(cgret);
}


1.

function freturn = f(n)
  x = 0.0e0;
  for i = 1:n
    x = x + i;
    cgret = x;
  end
  freturn = cgret;


2.

func f (n: Int32) -> Double {
  var x: Double
  var i: Int32
  var cgret: Double
  x = 0.0e0
  for i in 1...n
  {
    x = x + i
    cgret = x
  }
  return(cgret);
}

3.

f <- function(n)
{
  x <- 0.0e0
  for(i in 1 : n)
  {
    x <- x + i
    cgret <- x
  }
  return(cgret)
}

4.

function f(n)
    x = 0.0e0
    for i = 1:n
        x = x + i
        cgret = x
    end
    return(cgret)
end

5.

function f(n) {
  var x;
  var i;
  var cgret;
  x = 0.0e0;
  for (i in 1...n)
  {
    x = x + i;
    cgret = x;
  }
  return(cgret);
}

6.

      doubleprecision function f (n)
        integer n
        doubleprecision x
        integer i
        doubleprecision cgret
        x = 0.0D0
        do 100, i = 1, n, 1
          x = x + dble(i)
          cgret = x
100     continue
        f = cgret
        return
      end

7.

sub f
{
  local($n) = @_;
  local($x, $i, $cgret);
  $x = 0.0e0;
  for ($i = 1; $i <= $n; $i++)
  {
    $x = $x + $i;
    $cgret = $x;
  }
  return($cgret);
}

8. 

Public Module CodeGenerationModule
  Public Function f(ByVal n As Integer) As Double
    Dim x As Double
    Dim i As Integer
    Dim cgret As Double
    x = 0.0E0
    For i = 1 To n
      x = x + CDbl(i)
      cgret = x
    Next
    Return cgret
  End Function
End Module