interface number {} class integer : number { public int x; public integer(int a) {x=a;} } class rational : number { public int n, d; // numerator and denominator public rational(int a,int b) { n=a; d=b; } } class real : number { public double r; public real(double a) { r=a; } } public class ttt { number times(integer A, integer B) => new integer(A.x*B.x); number times(integer A, rational B) => new rational(A.x*B.n, B.d); number times(integer A, real B) => new real((double)A.x * B.r); number times(rational A,rational B) => new rational(A.n*B.n,A.d*B.d); number times(rational A,real B) => new real((double)A.n*B.r/(double)A.d); number times(real A, real B) => new real(A.r*B.r); number times(number A, number B) => times(B,A); number product(number[] N) { // find product of an array of numbers number ax = new integer(1); foreach(var n in N) ax = times(ax,n); return ax; } static bool equals(integer A, integer B) => A.x == B.x; static bool equals(integer A, rational B) => A.x*B.d == B.n; static bool equals(integer A, real B) => (double)A.x == B.r; static bool equals(rational A, rational B) => A.n*B.d == A.d*B.n; static bool equals(rational A, real B) => (double)A.n == B.r*(double)A.d; static bool equals(real A, real B) => A.r == B.r; static bool equals(number A, number B) => equals(B,A); public static void Main() { }//main }