
Error con BigInteger
Publicado por Lucho9964 (17 intervenciones) el 02/04/2020 22:41:44
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import java.util.Scanner;
import java.math.BigInteger;
public class Primos{
public static void main(String args[]){
Scanner usuario = new Scanner(System.in);
BigInteger b;
BigInteger c;
System.out.println("********************************************************");
System.out.println("* Bienvenido al programa que le encuentra los primos *\n* de un rango que usted mismo determina *");
System.out.println("********************************************************");
System.out.println("Digite el valor minimo del rango");
b = usuario.nextBigInteger();
System.out.println("Digite el valor maximo del rango");
c = usuario.nextBigInteger();
System.out.println("Los numeros primos que estan dentro de su rango son: ");
while(b<=c){
if(b==2 || b==3 || b==5 || b==7 || b!=1 && b%2!=0 && b%3!=0 && b%5!=0 && b%7!=0){
System.out.print(b+" ");
}
b++;
}
}
}
*****************************************
* error: *
*****************************************
Primos.java:23: error: bad operand types for binary operator '<='
while(b<=c){
^
first type: BigInteger
second type: BigInteger
Primos.java:24: error: incomparable types: BigInteger and int
if(b==2 || b==3 || b==5 || b==7 || b!=1 && b%2!=0 && b%3!=0 && b%5!=0 && b%7
!=0){
^
Primos.java:24: error: incomparable types: BigInteger and int
if(b==2 || b==3 || b==5 || b==7 || b!=1 && b%2!=0 && b%3!=0 && b%5!=0 && b%7
!=0){
^
Primos.java:24: error: incomparable types: BigInteger and int
if(b==2 || b==3 || b==5 || b==7 || b!=1 && b%2!=0 && b%3!=0 && b%5!=0 && b%7
!=0){
^
Primos.java:24: error: incomparable types: BigInteger and int
if(b==2 || b==3 || b==5 || b==7 || b!=1 && b%2!=0 && b%3!=0 && b%5!=0 && b%7
!=0){
^
Primos.java:24: error: incomparable types: BigInteger and int
if(b==2 || b==3 || b==5 || b==7 || b!=1 && b%2!=0 && b%3!=0 && b%5!=0 && b%7
!=0){
^
Primos.java:24: error: bad operand types for binary operator '%'
if(b==2 || b==3 || b==5 || b==7 || b!=1 && b%2!=0 && b%3!=0 && b%5!=0 && b%7
!=0){
^
first type: BigInteger
second type: int
Primos.java:24: error: bad operand types for binary operator '%'
if(b==2 || b==3 || b==5 || b==7 || b!=1 && b%2!=0 && b%3!=0 && b%5!=0 && b%7
!=0){
^
first type: BigInteger
second type: int
Primos.java:24: error: bad operand types for binary operator '%'
if(b==2 || b==3 || b==5 || b==7 || b!=1 && b%2!=0 && b%3!=0 && b%5!=0 && b%7
!=0){
^
first type: BigInteger
second type: int
Primos.java:24: error: bad operand types for binary operator '%'
if(b==2 || b==3 || b==5 || b==7 || b!=1 && b%2!=0 && b%3!=0 && b%5!=0 && b%7
!=0){
^
first type: BigInteger
second type: int
Primos.java:27: error: bad operand type BigInteger for unary operator '++'
b++;
^
11 errors
Valora esta pregunta


0