CRC32(第12个梅森素数) 代码

栏目: Java · 发布时间: 7年前

内容简介:梅森素数列表:https://blog.csdn.net/classmonster/article/details/50375131?utm_source=blogxgwz4第12个梅森素数的数值为 2^89-1,通过java代码可以算出2^89次方数值得出第12个梅森素数结果为:618970019642690137449562111

梅森素数列表:https://blog.csdn.net/classmonster/article/details/50375131?utm_source=blogxgwz4

第12个梅森素数的数值为 2^89-1,通过 java 代码可以算出2^89次方数值

public static StringBuffer my_power_2(int N){
		StringBuffer v = new StringBuffer("");
		long num[] = new long[2];
	    num[1] = 1;
	    if(N > 62){
	       num[0] = 1;
	       num[0] = num[0]<<(N - 62);
	       num[1] = num[1]<<62;
	       String s = String.valueOf(num[1]);
	       int size = 30,i = 0,j = 0;
	       long n[] = new long[size + 1];
	       //System.out.println(num[0]+" "+s);
	       for(i = s.length() - 1;i >= 0;-- i){
	    	   n[j ++] = num[0] * (s.charAt(i) - '0');
	    	   //System.out.println(n[j - 1]);
	       }
	       for(i = 0;i < size;++ i){
	    	   while(n[i] > 9){
	    		   n[i + 1] += n[i] / 10;
	    		   n[i] %= 10;
	    	   }
	       }
	       boolean bl = false;
	       for(i = size;i >= 0;-- i){
	    	   if(n[i] != 0 || bl){
	    		   v.append(n[i]);
	    		   bl = true;
	    	   }
	       }
	    }else{
	       num[1] = num[1] << N;
	       v.append(String.valueOf(num[1]));
	    }   
	    return v;
	}
int n = Integer.parseInt("89");
String string = my_power_2(n).toString();
System.out.println(string);

得出第12个梅森素数结果为:618970019642690137449562111

通过java代码进行CRC32加密:

CRC32 crc32 = new CRC32();
crc32.update("618970019642690137449562111".getBytes());
System.out.println(crc32.getValue());

得出结果为: 2820302374

然而Tinker的QQ群人数上限,还是无法进入。弃坑


以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Programming Concurrency on the JVM

Programming Concurrency on the JVM

Venkat Subramaniam / The Pragmatic Bookshelf / 2011-6-1 / USD 35.00

Concurrency on the Java platform has evolved, from the synchronization model of JDK to software transactional memory (STM) and actor-based concurrency. This book is the first to show you all these con......一起来看看 《Programming Concurrency on the JVM》 这本书的介绍吧!

JSON 在线解析
JSON 在线解析

在线 JSON 格式化工具

XML、JSON 在线转换
XML、JSON 在线转换

在线XML、JSON转换工具

html转js在线工具
html转js在线工具

html转js在线工具