Posted By

hejaaa on 06/03/11


Tagged

prime Marsenne


Versions (?)

Mersenne prime


 / Published in: ActionScript 3
 

Only simple search marsenne prime

  1. for (var i:Number = 2; i<10000; i++) {
  2. if (isPrime(i)) {
  3. for (var j:Number=2; j < i; j++) {
  4. if (i==Math.pow(2,j)-1) {
  5. trace("Marsen", i);
  6. }
  7. }
  8. }
  9. }
  10.  
  11. function isPrime(num) {
  12. for (var i=(num-1); i > 1; i--) {
  13. if ((num % i) == 0) {
  14. return false;
  15. }
  16. }
  17. return true;
  18. }

Report this snippet  

You need to login to post a comment.