I just started exploring APL. Though, familiar with C++ and python, I got stuck executing a simple program 'Print first n odd numbers' where n is the input in APL. Please help APL coders.
Asked
Active
Viewed 561 times
1 Answers
5
You mean you got stuck implementing that APL program?
Mathematically, odd numbers are of the form 2i+1. In APL the expression ⍳n
gives us the integers 0
through n-1
(assuming index origin 0). To obtain the desired result, multiply those by two and add one:
1+2×⍳n

ngn
- 7,763
- 6
- 26
- 35