Wednesday, January 26, 2005
Spring 2005 schedule
another semester starts!
dumpage of junks inside my...well inside me.
so, I want to keep gentoo now for my desktop.
but for the laptop, I'll maybe try arch or peanut.
I think peanut is good for live recovery cd....
I might install ubuntu on laptop...
/**
* skynare
* Prime Testing..
* Jan 4 2005
*/
import java.io.*;
public class Prime {
public static boolean isPrime( long p ) {
//long bound = Math.round( Math.sqrt(p) )++;//ceiling of p^(1/2)
//boolean found = false;
for( long i=2; i<=Math.sqrt(p); i++ ) {//starting from the smallest prime
//to the square root of p.
if( p%i == 0 ) {//found divisor of p [2, p^(1/2)]
return false;//so, p is not a prime
}//if
}//for
//not found a divisor of p in [2, p^(1/2)]
return true;//so, p is a prime.
}//isPrime
public static void main ( String args[] ) throws IOException {
String fileName = "primetable.txt";
long bound = Math.round( Math.pow(2, 63) ) - 1;
//long bound = 7919;
PrintWriter output = new PrintWriter( new OutputStreamWriter(
new FileOutputStream(fileName)) );
int count = 0;
for( long i=2; i<=bound; i++ ) {
if( isPrime(i) ) {
output.print(i+"\t");
count++;
}//if
if( count == 10 ) {
output.println();
count = 0;
}//if
}//for
output.close();
}//main
}//Prime
int len = fetch primetable.txt from ftp://International Prime Institution.net and calculate # of primes in the table;
unsigned int[] prime_set = new int[len];//let's say that len is 34253252365323
int product = 1;
for( int i=0; iproduct *= prime_set[i];
}//for
product++;
if( isPrime(product) ) {
System.out.println("IPI owned. I found new prime that doesn't belong to the primetable.txt which they say includes all primes. lol");
}//if
else {
System.out.println("the function isPrime(int) is not working properly. lol");
}//else
public static boolean isPrime( int p ) {
int count = 0;
for( int i=1; i<=Math.sqrt(p); i++ ) {
if( p%i == 0 ) {
count++;
}//if
if( count == 3 ) {//p is not prime
return false;
}//if
}//for
return true;
}//isPrime