2. Program
How to Print this series ? 1, 4, 9, 25, 49, 121......N
import java.util.Scanner; class Series2 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.print("Enter the range greater then 0 : "); int n = sc.nextInt(); int i = 1, j=1; if(n>0) { while(i <= n) { if(j%4!=0) { i = j*j; System.out.print(i + " "); } j++; } } else{ System.out.print("Enter the range greater then 0 : "); } } }