Java - recursivo decimal a binario ayudaaaa

 
Vista:
sin imagen de perfil

recursivo decimal a binario ayudaaaa

Publicado por MRX (16 intervenciones) el 20/03/2018 01:43:24
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
31
32
33
34
35
package taller2punto1ydos;
 
import java.util.Scanner;
 
public class punto2opcion2 {
 
	private static Scanner sc;
	private static Scanner leer;
 
	public punto2opcion2() {
		// TODO Auto-generated constructor stub
	}
 
	public static void main(String[] args) {
		// TODO Auto-generated method stub
 
		long n;
		long cifra;
		long  res=0;
		long  exp=0;
		leer = new Scanner(System.in);
		System.out.println("   ingrese el numero entero   ");
		n=leer.nextInt();
 
 
		do {
			cifra=n%10;
			res=res+cifra*(int)Math.pow(2,exp);
			exp++;
			n=n/10;
 
		}while(n>0);
		System.out.print("");
	}
}



nesecito que este recursivo & Que no lleve ciclos
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder