![]() |
https://market.android.com/details?id=com.mathConstants |
private BigDecimal generatePi(int nrOfDigits){
BigDecimal cPi = new BigDecimal("0");
BigInteger fct = new BigInteger("1");
BigInteger fct3 = new BigInteger("1");
BigInteger fct6 = new BigInteger("1");
BigInteger nominator = new BigInteger("0");
BigInteger someOfDenominator = new BigInteger("0");
BigDecimal oldVal = new BigDecimal("0");
BigDecimal newVal = new BigDecimal("0");
int k = 1;
BigInteger sign = new BigInteger("1");
BigInteger pSign = new BigInteger("1");
BigInteger nSign = new BigInteger("-1");
BigInteger bD13591409 = new BigInteger("13591409");
BigInteger bD545140134 = new BigInteger("545140134");
BigInteger bD640320 = new BigInteger("640320");
nrOfDigits +=10;
BigDecimal sqrtBD640320 = BigSqrt(new BigDecimal(bD640320), nrOfDigits);
nominator = bD13591409;
someOfDenominator = bD640320;
newVal = (new BigDecimal(nominator)).divide(new BigDecimal(someOfDenominator), nrOfDigits, BigDecimal.ROUND_HALF_EVEN);
do {
if (this.isCancelled()){
return new BigDecimal("0");
}
if ((k % 2) == 0){
sign = pSign;
}else{
sign = nSign;
}
oldVal = newVal;
fct = fct.multiply(mulRange(k, k));
fct3 = fct3.multiply(mulRange(3*(k-1)+1, 3*k));
fct6 = fct6.multiply(mulRange(6*(k-1)+1, 6*k));
nominator = sign.multiply(fct6).multiply(bD13591409.add(bD545140134.multiply(BigInteger.valueOf(k))));
someOfDenominator = fct3.multiply(fct.pow(3)).multiply(bD640320.pow(3*k+1));
newVal = oldVal.add((new BigDecimal(nominator)).divide((new BigDecimal(someOfDenominator)), nrOfDigits, BigDecimal.ROUND_HALF_EVEN));
k++;
} while (newVal.compareTo(oldVal) != 0);
newVal = newVal.divide(sqrtBD640320, nrOfDigits, BigDecimal.ROUND_HALF_EVEN);
BigDecimal bD12 = new BigDecimal("12");
BigDecimal bD1 = new BigDecimal("1");
cPi = bD12.multiply(newVal);
nrOfDigits -= 10;
cPi = bD1.divide(cPi, nrOfDigits-1, BigDecimal.ROUND_DOWN);
return cPi;
}
![]() |
https://market.android.com/details?id=com.collatz |
|
|
|
|
I have made a game of Nine Men's Morris.
Below is a screen capture of the game. I was going to make the game using a genetic algorithm to find a good
fully connected feed forward neural network with 2 hidden layers. It turned out to give a very
low playing strength.
I have now instead made an implementation using the traditional alpha-beta pruning algorithm and now it plays better,
beating most human players including
myself.
There is also hash table support but no multi processor support. The latest version has updates in the
GUI and the pieces can now slide across the board, the user can change the colours of the game as well.
The link is to an installation file and Microsoft .NET framework version 3.5 is a requirement for the program to run.
|
|
This Program is Freeware. You are welcome to download it. It is possible to play a game of mancala against the computer on a difficult level if you set the level accordingly.
Screen capture from Mancala
|
mancala.zip from Yahoo Geocities. mancala.zip 1.950 KB. With this freeware program. You are able to play a beta version of Mancala. Not compiled to native code however. |
Screen capture from Cube.exe
|
Cube.zip 90 KB. The program displays an elastic cube moving around in a bigger
solid cube. It's possible to change some parameters on the run. Programming tip: To synchronize the program with the screen raster the following lines are included in the C source code: while( (inp(0x03da) & 0x08)= =0x08); while( (inp(0x03da) & 0x08)!=0x08); VGA input status #1 register has port address 0x03da for color mode. Bit 3 in this register is 0 during the monitors display phase and 1 during the vertical retrace phase. |
Proposition: There are infinite many prime numbers.
Proof: Suppose there is only a finite number p1, p2, p3,....,pn of primes.
Then a pi that divides N+1=(p1*p2*p3*...*pn)+1 must exist among them.
We then have (((N+1)/pi)-(N/pi))=1/pi. But it is absurd that pi divides 1.
So our list of primes cannot have been complete.
It is however a little more difficult to prove that there are an infinite number
of prime number twins. 2 prime numbers pn and pm are twins if pm-pn=2.
It has not yet been proven whether there is an infinite or only a finite number of
prime number twins.
Here is a prime number link:
The Prime Page (An Index of Information on Prime Numbers)
This Java applet is made in 1.1 code if it doesn't run it might do on a newer web browser.
The program tests if 2 or an odd number smaller than or equal to the square root of the number divides.
The 3n+1 problem is to prove or disprove that if a number sequence is generated by
na+1=na/2 if na MOD 2 = 0 and
na+1=na*3+1 if na MOD 2 <> 0
Then no matter what positive integer is taken as the seed number. The sequence will
always end up like 1 4 2 1 4 2 1 4 .....
The 3*n - 1 number sequences can end up in more than one way.
If you want to put this on your page: Copy the primfact.class and the Getbuttonpress.class to your html directory and put the line:
<applet code=primfact.class width=725 height=525></applet>in your html file.
Version 1.01
MouseClick to go:
Since May 17, 2009 this page has had an access count of:
