LISP lambda calculate, expression
5) SUM OF CUBES OF FIRST N POSITIVE NNUMBERS
Fist of all know that java , c++ and other where you hide the details of operation from user is the absttract proggramming language.
so heres the program for cube addition in jva as a function
import java.util.*;
import java.lang.*;
public class CubeSum {
/* Returns the sum of series */
public static int cubeSum(int n)
{
int x;
if (n % 2 == 0)
x = (n/2) * (n+1);
else
x = ((n + 1) / 2) * n;
return x * x;
}
// Main function for calling of cubeSum()
public static void main(String[] args)
{
int n;
Scanner reader = new Scanner(System.in); // Reading from System.in
System.out.println("Enter a number: ");
n = reader.nextInt(); // Scans the next token of the input as an int.
//once finished
reader.close();
int sum=cubeSum(n);
System.out.println("Sum of cubeis of first "+n+" numbers is "+sum);
}
}
LISP lambda calculate, expression 3) Consider reducing the following λ-expression to its normal form. Show the...