Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class quadrato {
- public static void main (String args[]) {
- int N;
- int i;
- int num;
- int quad=0;
- Scanner kb=new Scanner (System.in);
- System.out.println ("Inserisci il numero N:"); //Chiedo il numero.
- N=kb.nextInt();
- for (i=1;i<=N*2;i+=2) {
- quad=quad+i;
- }
- System.out.println(+N+ " al quadrato vale "+quad+ ".");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement