Public static int poweroftenint i int power 1 whilei0

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: blic static int Power_of_Ten(int i) { int power = 1; while(i>0) { power = power*10; i = i-1; } return power; } 11 The method for Max Digit public static int Max\_Digit\_Index(int n, int digits) { int max_digit = n%10; int max_digit_index=1; n = n/10; for(int i=2; i<=digits; i = i+1) { int current_digit = n%10; if(current_digit>max_digit) { max_digit = current_digit; max_digit_index = i; } n = n/10; } } 12 The method : Value of Digit of n at Index() // function for computing the digit of n at ’index’ public static int Value_of_Digit_of_n_at_Index(int n, int index) { int power = Power_of_Ten(index-1); n = n/power; return(n%10); } 13 The method : Permutation with Max Digit at MSI public static int Permutation_with_Max_Digit_at_MSI(int n, int digits) { int power = Power_of_Ten(digits-1); int digit_at_MSI = n/power; int max_digit_index = Max_Digit_Index(n,digits); int value_of_max_digit = Value_of_Digit_of_n_at_Index(n,max_digit_index); int new_n=n; if(max_digit_in...
View Full Document

Ask a homework question - tutors are online