Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner xr = new Scanner(System.in);
- int num = xr.nextInt();
- int tamaño = ((num*(num-1))/2)+num;
- int arreglo[] = new int [tamaño];
- //Creamos la sucesion
- int cont = 0;
- int pares = 0;
- int impares = 0;
- for (int i = 1; i<=num; i++) {
- for (int j = i; j > 0; j--) {
- arreglo[cont] = (i*i);
- if(arreglo[cont] % 2 == 0){
- pares++;
- }else{
- impares++;
- }
- System.out.print("1/"+(i*i)+" + ");
- cont++;
- }
- }
- System.out.println("\nPares: "+pares);
- System.out.println("Impares: "+impares);
- for(int temporal:arreglo){
- System.out.print(temporal+" ");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement