Home
 
 
 
 
 
Site Navigation

Home

Web Apps

Challenges

Events

Our Members

Contact Us

 

 

Without actually entering the following code into a java editor, figure out what the program will print out.

----------------------------------------------------------------------------------------------------------------------------

public class MysteryRecursion {
        private static int m(int n, int f) {
                if (f == 1)
                        return n;
                return (int)((n%10)*Math.pow(10, f-1) + m((n-n%10)/10, f-1));
        }
        public static int mystery(int n){
                return m(n, (int)(Math.log10(n)+1));
        }
        public static void main(String[] args) {
                System.out.println(mystery(1928374));
        }
}

 
 
 

Content on this page requires a newer version of Adobe Flash Player.

Get Adobe Flash player

Links

Download Eclipse

NSHS Website

 
 

Copyright © 2010 NSHS Programming Team

Designed by Jiaji Chen