Advertisement
whiplk

[CODE] - Números perfeitos

Mar 16th, 2013
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.59 KB | None | 0 0
  1. //By Willian Luigi.
  2. // Você digita quantos números quer e ele te mostrar os números perfeitos existentes na faixa que você pedir.
  3.  
  4. import java.util.*;
  5. public class Perfeitos {
  6.     public static void main(String[] args) {
  7.         Scanner inp = new Scanner(System.in);
  8.         System.out.print("Informe quantos números perfeitos você deseja de retorno: ");
  9.         int n = inp.nextInt();
  10.         System.out.printf("%d\n", (((int)Math.pow(2,1))*(((int)Math.pow(2,2)) - 1)));
  11.         for (int i = 1, j = 2; i <= n - 1; i++, j += 2) {
  12.             System.out.printf("%d\n", (((int)Math.pow(2,j))*(((int)Math.pow(2,j+1)) - 1)));
  13.         }  
  14.     }
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement