Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //By Willian Luigi.
- // Você digita quantos números quer e ele te mostrar os números perfeitos existentes na faixa que você pedir.
- import java.util.*;
- public class Perfeitos {
- public static void main(String[] args) {
- Scanner inp = new Scanner(System.in);
- System.out.print("Informe quantos números perfeitos você deseja de retorno: ");
- int n = inp.nextInt();
- System.out.printf("%d\n", (((int)Math.pow(2,1))*(((int)Math.pow(2,2)) - 1)));
- for (int i = 1, j = 2; i <= n - 1; i++, j += 2) {
- System.out.printf("%d\n", (((int)Math.pow(2,j))*(((int)Math.pow(2,j+1)) - 1)));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement