In this program, You will learn how to print first n odd numbers in descending order in R.
Example: How to print first n odd numbers in descending order in R
1 2 3 4 5 6 7 8 9 10 11 12 |
{ num = as.integer(readline(prompt = "Enter a number :")) num = num - 1 for (i in num:0) { a = 1 + i * 2 print(paste(a)) } } |
Output:
1 2 3 4 5 6 7 8 9 |
Enter a number :6 [1] "11" [1] "9" [1] "7" [1] "5" [1] "3" [1] "1" |