Thread: Fast way to square??? View Single Post
 2004-05-28, 16:26 #1 maheshexp   May 2004 52 Posts Fast way to square??? can any one help me to find out wheather it multiples faster to get the "square of a number i.e x^2 "or not. if you have better solution , could u please give me. y(1) = 1; y(n) = y(n-1) + ( 1 + 2* (n-1)), n > 1 eg: to find 4^2 y(1) = 1 y(2) = y(1) + (1 + 2*(1)) => 4 y(3) = y(2) + (1 + 2*(2)) => 9 y(4) = y(3) + (1 + 2*(3)) => 16 A CPP Program.... Code: `void test2() { long long max = 60000; long long y = 1; time_t t1, t2; time(&t1); for (long long j = 0; j < max / 3; j++) for (long long i = 1; i <= max; i++) { y = i * i; } time(&t2); cout<<"muls:\n\t"<<"t1:" << t1 << "\n\tt2:" <