-
Bug
-
Resolution: Won't Fix
-
P4
-
None
-
1.2.0
-
x86
-
windows_nt
Name: vi73552 Date: 06/18/99
Run this java class:
/*******************************************************************************
* class PrijsFaculteiten
*
* @author Karsten van Zwol
* @version 1.0
* @since JDK1.2
*******************************************************************************/
class PrijsFaculteiten
{
/*****************************************************************************
* function fac calculates:
* n! = n * (n-1) * (n-2) * ... * 2 * 1
*
* param@ n the nr n in n!
* return n! = n * (n-1) * (n-2) * ... * 2 * 1
*****************************************************************************/
static long fac(long n)
{
if (n > 0) return n * fac(n - 1); else return 1;
}
/*****************************************************************************
* the main function
*
* param@ args[] command line arguments
*****************************************************************************/
public static void main(String args[])
{
byte remainder;
long digitsAdded, tmpNr;
long facArray[] = new long[10];
for (int i=0; i < facArray.length; i++)
facArray[i] = fac(i);
for (long nr=1; nr < 100000; nr++)
{
tmpNr = nr;
digitsAdded = 0;
while (tmpNr != 0)
{
// calculate the remainder of tmpNr / 10
// this results in the most right digit.
// Example: 1234 % 10 = 4
remainder = (byte)(tmpNr % 10);
// add fac(remainder) from the facArray
digitsAdded += facArray[remainder];
// move the number one digit to the right.
// Example: 1234 / 10 = 123
tmpNr /= 10;
} // end of while
// check for match
if (digitsAdded == nr) System.out.println("Match found : " + nr);
} // end of for
} // end of main
}
output:
A nonfatal internal JIT (3.00.078(x)) error 'GetRegisterA' has occurred in :
'PrijsFaculteiten.main ([Ljava/lang/String;)V': Interpreting method.
Please report this error in detail to http://java.sun.com/cgi-bin/bugreport.cgi
Match found : 1
Match found : 2
Match found : 145
Match found : 40585
problem is the statment: tmpNr /= 10;
(Review ID: 84528)
======================================================================