Wednesday 22 June 2011

Find prime numbers/prime factors

simple algorithm to find prime numbers and prime factors
depending on the value of N

void setup() {
long N =463;
for (long i = 2 ; i <= N ; i++) {
while (N % i == 0) {
System.out.println(i);
N = N/i;
}
}
}

No comments:

Post a Comment