Write a program to print all odd numbers from 1 to n using for loops

Write a program to print all odd numbers from 1 to n using for loops

Example:-

Input :-
n=7
Output :-
1
3
5
7

1 Like

function print_series(n){

  for(var i=0;i<=n;i++)
  {
      if(i%2!==0)
      {
      console.log(i);
  }
  }

}
print_series(7)

1 Like

Very good. Keep learning :fire: