R Program to print first n odd numbers in descending order


In this program, You will learn how to print first n odd numbers in descending order in R.


List of odd numbers in descending order's :19, 17, 15, 13, 11, 9, 7, 5, 3, 1

Example: How to print first n odd numbers in descending order in R

{
    num = as.integer(readline(prompt = "Enter a number :"))

    num = num - 1

    for (i in num:0) {
      a = 1 + i * 2
      print(paste(a))
    }
}

Output:

Enter a number :6
[1] "11"
[1] "9"
[1] "7"
[1] "5"
[1] "3"
[1] "1"