Skip to content

Instantly share code, notes, and snippets.

@i0nyx
Last active November 24, 2021 14:22
Show Gist options
  • Save i0nyx/1f629c7186495b6d7c75a6f0ee9ae948 to your computer and use it in GitHub Desktop.
Save i0nyx/1f629c7186495b6d7c75a6f0ee9ae948 to your computer and use it in GitHub Desktop.
Glava 1
/*
Написать программу, которая выводит на экран первые четыре
степени числа n.
*/
package gl_1.zadanie_gl_1;
import java.util.Scanner;
public class N_1 {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc = new Scanner(System.in);
System.out.println("Введите число:");
int n = 0;
if(sc.hasNextInt()){
n = sc.nextInt();
}else{
System.out.println("Вы ввели не целое число либо строку!");
}
for(int i = 1; i <= 4; i++){
int x = (int)Math.pow(n, i);
System.out.println(n + " в степени " + i + " = " + x);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment