September 2017 Update
This commit is contained in:
parent
bba7bfd280
commit
ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions
|
|
@ -1,52 +1,45 @@
|
|||
public class AksTest
|
||||
{
|
||||
static Long[] c = new Long[100];
|
||||
|
||||
public static void main(String[] args)
|
||||
{
|
||||
for (int n = 0; n < 10; n++) {
|
||||
coef(n);
|
||||
System.out.print("(x-1)^" + n + " = ");
|
||||
show(n);
|
||||
System.out.println("");
|
||||
}
|
||||
|
||||
System.out.print("Primes:");
|
||||
for (int n = 1; n <= 63; n++)
|
||||
if (is_prime(n))
|
||||
System.out.printf(" %d", n);
|
||||
|
||||
System.out.println('\n');
|
||||
}
|
||||
|
||||
static void coef(int n)
|
||||
{
|
||||
int i, j;
|
||||
|
||||
if (n < 0 || n > 63) System.exit(0); // gracefully deal with range issue
|
||||
|
||||
for (c[i=0] = 1l; i < n; c[0] = -c[0], i++)
|
||||
for (c[1 + (j=i)] = 1l; j > 0; j--)
|
||||
c[j] = c[j-1] - c[j];
|
||||
}
|
||||
|
||||
static boolean is_prime(int n)
|
||||
{
|
||||
int i;
|
||||
|
||||
coef(n);
|
||||
c[0] += 1;
|
||||
c[i=n] -= 1;
|
||||
|
||||
while (i-- != 0 && (c[i] % n) == 0);
|
||||
|
||||
return i < 0;
|
||||
}
|
||||
|
||||
static void show(int n)
|
||||
{
|
||||
do {
|
||||
System.out.print("+" + c[n] + "x^"+ n);
|
||||
}while (n-- != 0);
|
||||
}
|
||||
public class AksTest {
|
||||
private static final long[] c = new long[64];
|
||||
|
||||
public static void main(String[] args) {
|
||||
for (int n = 0; n < 10; n++) {
|
||||
coeff(n);
|
||||
show(n);
|
||||
}
|
||||
|
||||
System.out.print("Primes:");
|
||||
for (int n = 1; n < c.length; n++)
|
||||
if (isPrime(n))
|
||||
System.out.printf(" %d", n);
|
||||
|
||||
System.out.println();
|
||||
}
|
||||
|
||||
static void coeff(int n) {
|
||||
c[0] = 1;
|
||||
for (int i = 0; i < n; c[0] = -c[0], i++) {
|
||||
c[1 + i] = 1;
|
||||
for (int j = i; j > 0; j--)
|
||||
c[j] = c[j - 1] - c[j];
|
||||
}
|
||||
}
|
||||
|
||||
static boolean isPrime(int n) {
|
||||
coeff(n);
|
||||
c[0]++;
|
||||
c[n]--;
|
||||
|
||||
int i = n;
|
||||
while (i-- != 0 && c[i] % n == 0)
|
||||
continue;
|
||||
return i < 0;
|
||||
}
|
||||
|
||||
static void show(int n) {
|
||||
System.out.print("(x-1)^" + n + " =");
|
||||
for (int i = n; i >= 0; i--) {
|
||||
System.out.print(" + " + c[i] + "x^" + i);
|
||||
}
|
||||
System.out.println();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue