Recently saw such a problem, there are a pile of peach total unknown, there are 5 monkeys. In the morning a monkey came to the peach before the average divided into 5 but one more, the more one ate and then took away one of the remaining four. The second monkey came and divided the remaining peaches into 5 parts. One more to eat and then take away one of the remaining four. The third one ... Every monkey does the same. Ask this pile of peaches at least how many.
Write your own hand for reference only, if there are problems and improve the look left to improve the method
public static void Main (string[] args) {
Star ();
}
public static int star () {
int a = 1; Suppose the last time you divide it into a
int i = 6; The last time the peach was divided into 6 total
int b = 5; Record Count Reverse This is the 5th monkey.
while (true) {
if (5*i%4==0) {///The total number of the previous peach count is a positive integer
i=5*i/4+1; Get the last number of peaches
b--; Number is the last time
System.out.println ("=========" +b);
System.out.println (i);
}else{//To determine whether the previous number of peach count is a positive integer is not a positive integer from new to a value plus 1 set the last time to divide the draw number plus 1
a++; A value plus 1 for the last time to divide the draw number plus 1
i=5*a+1;//so the last time the number of peaches will be calculated from the new
b=5; Times starting from 5
}
if (b==1) {//when the number of 1 o'clock represents 5 can be divided to determine the starting total
Break
}
}
return i; Return the result at least I
}