Dain1234 / Java-Programming

0 stars 0 forks source link

Nth odd after n #18

Open Dain1234 opened 1 year ago

Dain1234 commented 1 year ago

package com.dain.logics;

import java.util.Scanner;

public class NthAfterN { public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.println("Enter the nth odd:"); int n = sc.nextInt(); int j = 1; int arr[] = new int[100]; for (int i = 0; i <= 100; i++) { if (i % 2 != 0) { arr[j] = i; j++;

        }

    }
    System.out.println(arr[n * 2]);

}

}