title: Find the sum of first 'N' whole numbers by using conditions?
body: <p>Could you please write a code in R language for the following</p>
  
  <p>Find the sum of first 20 whole number by using while/for or IF conditions. </p>
  
  <p>I tried writing the following code, please correct </p>
  
  <pre><code>x=1
  while(x&gt;0) 
  {
   x&lt;- x+1 
   sum= sum + x  
   if(x==20)
     break 
   print(sum)
  } 
  </code></pre>
  
  <p>Also suggest me the alternatives. so that I can learn different ways of writing a code. </p>