print 1 to n number with out using second variable in java?
<p>print 1 to n number with out using second variable</p>

<p>i wrote like this</p>

<pre><code>System.out.println("enter the input number");
int input = sc.nextInt();
</code></pre>

<p>one variable is input but we again we does't use another varible. so i stacked here.</p>

<p>if i write like this it display 1 to max value of Integer but here i am not taking input value</p>

<pre><code>for(int i=1;i&lt;Integer.MAX_VALUE;i++)
{
System.out.println(i);
}
</code></pre>

<p>if i write like this i taking two varibles</p>

<pre><code>for(int i=1;i&lt;input;i++)
{
System.out.println(i);
}
</code></pre>

<p>but i display up to max value of Integer number only but i want to display upto n number i.e what i given input number</p>