Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

NEED URGENT HELP

Name: edo-chan 2011-12-28 11:11

sup /prog/

Ive asked this everywer already but peopl seem too lame to make even a simple program like so i hope the mighty anon programers of 4chan are more skilled

what im trying to do is to Write a method taking two parameters x and n that computes the nth power of x without using ^ or declaring a new variable inside the method or using Math lib.
and it has to be coded in JAVA (i know it sux but dont ask why i use dat shit)
hep plox!

Name: Anonymous 2011-12-29 17:12

>>126
see >>120

public static double powr(int x,int n)
    {
        if(x == 1 || n == 0) return 1.0;
        return n < 0 ? (1.0/(powr(x,-n-1)*x)) : powr(x,n-1)*x;
    }

[ Thu Dec 29 05:04:42 ]
[ @ ~/host/prog ] $ java pow 2 10000
FOR:0.0
REC:Infinity
[ Thu Dec 29 05:00:02 ]
[ @ ~/host/prog ] $ java pow 2 560
FOR:0.0
REC:3.7739624248215414E168


you're retarded

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List