Java BigInteger类| nextProbablePrime()方法与示例

BigInteger类nextProbablePrime()方法 (BigInteger Class nextProbablePrime() method)

  • nextProbablePrime() method is available in java.math package.

    nextProbablePrime()方法在java.math包中可用。

  • nextProbablePrime() method is used to get the next probable prime number that should be higher than this BigInteger and there is a limit of composite number that should not exceed 2 pow(-100).

    nextProbablePrime()方法用于获取下一个可能大于此BigInteger的下一个素数,并且合成数的限制不得超过2 pow(-100)。

  • nextProbablePrime() method is a non-static method, it is accessible with the class object only and if we try to access the method with the class name then we will get an error.

    nextProbablePrime()方法是一种非静态方法,仅可通过类对象访问,如果尝试使用类名访问该方法,则会收到错误消息。

  • nextProbablePrime() method may throw an exception at the time of returning the next probable prime number.

    nextProbablePrime()方法在返回下一个可能的质数时可能会引发异常。

    ArithmeticException: This exception may throw when the value of this BigInteger is negative.

    ArithmeticException :如果此BigInteger的值为负,则可能引发此异常。

Syntax:

句法:

    public BigInteger nextProbablePrime();

Parameter(s):

参数:

  • None

    没有

Return value:

返回值:

The return type of this method is BigInteger, it returns BigInteger that holds the value larger than this BigInteger and it is probably prime.

此方法的返回类型为BigInteger ,它返回的BigInteger持有的值大于此BigInteger,并且它可能是素数。

Example:

例:

// Java program to demonstrate the example 
// of BigInteger nextProbablePrime() method of BigInteger
import java.math.*;
public class NextProbablePrimeOfBI {
public static void main(String args[]) {
// Initialize two variables str1 and str2
String str1 = "13";
String str2 = "6";
// Initialize two BigInteger objects  
BigInteger b_int1 = new BigInteger(str1);
BigInteger b_int2 = new BigInteger(str2);
// returns the next prime number
// of this BigInteger b_int1 so the value of
// this BigInteger is 13 then the next prime
// after 13 is 17
BigInteger next_prime = b_int1.nextProbablePrime();
System.out.println("b_int1: " + b_int1);
System.out.println("b_int1.nextProbablePrime(): " + next_prime);
System.out.println();
// returns the next prime number
// of this BigInteger b_int2 so the value of
// this BigInteger is 6 then the next prime
// after 6 is 7
next_prime = b_int2.nextProbablePrime();
System.out.println("b_int2: " + b_int2);
System.out.println("b_int2.nextProbablePrime(): " + next_prime);
}
}

Output

输出量

b_int1: 13
b_int1.nextProbablePrime(): 17b_int2: 6
b_int2.nextProbablePrime(): 7

翻译自: https://www.includehelp.com/java/biginteger-nextprobableprime-method-with-example.aspx

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/542386.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

SQL 行转列的两种做法

if object_id(tb)is not null drop table tbGocreate table tb(姓名 varchar(10),课程 varchar(10),分数 int)insert into tb values(张三,语文,74)insert into tb values(张三,数学,83)insert into tb values(张三,物理,93)insert into tb values(李四,语文,74)insert into tb…

android一个工程的xml怎么引用另外一个工程的xml,如何在Android中使用XML引用库中另一个包的字符串?...

Androiddocumentation告诉我,我可以使用“包名”访问另一个包中的字符串,无论这意味着什么:[:]/所以在我的清单中,我想访问一个字符串,我已将其放在一个单独的库项目中,在com.globalmentor.android包中 – 毕竟我的R类就是这样:android:label"com.g…

kotlin 类和对象_Kotlin程序| 类和对象的示例(带有学生数据)

kotlin 类和对象In the below program, we are creating a student class to input and print the student data like name, age. It is a simple example of creating class in Kotlin. 在下面的程序中,我们将创建一个学生班级,以输入和打印学生数据&am…

python 复数数组_python的数组运算及推导式的运用

运行方式:缩进 TAb(四格)或者space(1格)注释:#可以在程序后注释文字 或者 ... ,""" ... """ 可以多行注释 中间全为注释数值输出 print(...)图形输出 import matplotlib as pltplt.show()列表 list[] #字符串…

ActiveX: 如何用.inf和.ocx文件生成cab文件

ActiveX: 如何用.inf和.ocx文件生成cab文件 转载于:https://www.cnblogs.com/time-is-life/p/5977962.html

Android工具里没有Android,android – AppCompat工具栏没有显示

在主题中声明.NoActionBar之后,以及将工具栏放在布局中,我的工具栏不会显示.我最终得到的正是你在宣布没有动作栏时所期望的 – 没有动作栏.这是布局:activity_home.xml:layout"layout/app_bar_home"android:layout_width"match_parent&q…

操作系统中的处理机调度调度_操作系统中的多处理器调度

操作系统中的处理机调度调度多处理器操作系统 (Multiprocessor Operating system) A multiprocessor system consists of several processors which share memory. In the multiprocessor, there is more than one processor in the system. The reason we use multiprocessor …

转:Delphi2010新发现-类的构造和析构函数功能

Delphi2010发布了. 虽然凭着对Delphi的热爱第一时间就安装了,但是现在可能是年纪大了,对新事物缺乏兴趣了.一直都没有仔细研究. 今天有点时间试了一下新功能. 本来C#和Delphi.NET是支持类的构造函数/析构函数的(注意不是实例的构造和析构).也就是在模块初始化/卸载的时候会调用…

sed 替换_sed命令批量替换文件内容

“ 开发人员有时会大批量替换文件内容,sed命令是一个很好用的工具。”01—暴力替换方式近期有个临时任务,将系统中所有"帐"替换为"账",那"帐"和"账"有啥区别呢;1、账的部首是贝;帐的部首是巾。2、账是关于货币、…

android 模仿uc标签页,模仿UCweb菜单 - 白羽雕弓 - 博客园

UCWeb的菜单看起来不错,自己想模仿做一个,苦恼一直没有思路google了几天,终于找到一个帖子 http://www.eoeandroid.com/viewthread.php?tid28824按照上面提供的思路实现了1、保留menu按键作用2、用popupwindow作为菜单显示容器3、用GridVie…

ipv6路由协议配置_IPV6寻址,标头和路由协议

ipv6路由协议配置The IPV6 address is 128 bits. Whereas IPV4 is represented by 4 groups of decimal numbers, same IPV6 is represented by 8 groups of hexadecimal numbers. The example of IPV6 address is 2001:0db8:85a3:0000:0000:8a2e:0370:7334. IPV6地址是128位。…

rpc框架

Motan,dubbo转载于:https://www.cnblogs.com/zhangshiwen/p/5980886.html

android webview 监听js,Android webview与js的数据交互

项目要用到Webview和js交互,查了查以前的项目感觉还是有必要整理下的。简单描述下项目中用到的地方,比如说在web页需要用到登录的地方点击登录跳转到APP原生登录界面去登录,点击web页的拨打电话弹出原生dialog询问是否拨打,点击we…

c ++查找字符串_C ++异常处理| 查找输出程序| 套装1

c 查找字符串Program 1: 程序1&#xff1a; #include <iostream>using namespace std;int main(){try {int num1 10;int num2 0;int res 0;res num1 / num2;}catch (exception e) {cout << "Exception: Divide By Zero" << endl;}return 0;}O…

python的repr和str有什么不同_str()和repr()的异同

str()函数和repr()函数&#xff0c;都是Python内置的标准函数。这两个函数都是根据参数对象返回一个字符串&#xff0c;但是又有一些不一样的地方。我们在使用的时候&#xff0c;常常搞混&#xff0c;倾向于使用简单明了的str()函数&#xff0c;而搞不清楚为什么还有一个不知所…

android web通讯录,Android手机开发之通讯录

Android手机开发——通讯录实现增加、查询、修改、删除的功能&#xff0c;输入联系人信息&#xff0c;点击“添加”按钮&#xff0c;可以添加联系人信息到数据库&#xff1b;点击“查询”按钮&#xff0c;会发现添加的联系人信息显示在界面中&#xff1b;重新输入联系人电话&am…

有关UITableView--cell复用问题

近来用Tableview做了一个九宫格。过程中碰到了两个cell复用问题。 问题一&#xff1a; 在cell中为button添加addTarget点击事件时&#xff0c;出现后面的cell会重叠它前面cell的事件。代码如下&#xff1a; C代码 static NSString *CellWithIdentifier "DiscoverHomeTab…

python客户端和服务端实验_结合服务器和客户端python

我正在尝试使用python(稍后可能用c语言)和TCP套接字制作一个本地网络聊天程序。我的目的是让服务器监听当前计算机的地址以获取传入消息&#xff0c;并将这些消息转发给客户端(我现在还不确定)。客户端将是一个简单的gui&#xff0c;可以通过本地连接向活动服务器发送消息。实际…

python常用语法和示例_C语言切换案例教程,语法,示例和规则

python常用语法和示例使用默认情况下的决策 (Decision making using switch-case-default) Many times in our daily lives, we face conditions where we are required to choose between a number of alternatives rather than just two or three. For example, which school…

android so abi适配,Android NDK学习(六): so文件兼容之abiFilters的使用

最近项目中遇到了要使用JavaCV的情况&#xff0c;涉及到了abi兼容的选择。因为如果全部都适配的话&#xff0c;包很大&#xff0c;这样兼容那些用户数极少的cpu就很不划算&#xff0c;所以我只适配了armeabi-v7a这一个。但是今天在x64-v8a的模拟器上看的时候&#xff0c;提示我…