Yes, but it doesn't work🔪💔 Scanner sc = new Scanner(System.in); int number = sc.nextInt(); if(number >= -1000 && number <= 1000) { if(number < 0){ for (int i = Math.abs(number) ; i > 0 ; i--) { System.out.print( Math.pow(2, -i)); System.out.print(","); } System.out.print("1"); } else for (int i = 0; i <= number; i++ ) { System.out.print((int) Math.pow(2, i)); if (i < number) System.out.print(","); } }
Thank u so much Carsten for ur time.
Обсуждают сегодня