Xref: utzoo sci.math:17142 sci.misc:4979 comp.edu:4265 uw.general:3355 ut.general:1549 Newsgroups: sci.math,sci.misc,comp.edu,uw.general,ut.general Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!sarah!bingnews!kym From: kym@bingvaxu.cc.binghamton.edu (R. Kym Horsell) Subject: Re: Subtle Math Questions Message-ID: <1991Apr30.131955.17083@bingvaxu.cc.binghamton.edu> Organization: State University of New York at Binghamton References: <1991Apr30.002142.21112@jarvis.csri.toronto.edu> <1991Apr30.072900.7073@bingvaxu.cc.binghamton.edu> <1991Apr30.080102.9990@bingvaxu.cc.binghamton.edu> Date: Tue, 30 Apr 1991 13:19:55 GMT In article <1991Apr30.002142.21112@jarvis.csri.toronto.edu> blaak@csri.toronto.edu (Raymond Blaak) writes: >ghot@ms.uky.edu (Allan Adler) writes: >>(6) What are the last 4 digits of 5 to the 7777th power ? > >How about the FIRST 4 digits? > >Cheers, >Ray As I've had several requests for the secret of my posted solution: /* calculate ms 4 digits of 5^7777 */ ipow(ix,iy) { double u=1; double x=ix; while(x>1) x/=10; while (iy) { if(iy&1) { u*=x; while(10*u<1) u*=10; } x*=x; while(10*x<1) x*=10; iy>>=1; } return u*10000; } main() { printf("%d\n",ipow(5,7777)); } -kym