how to write algorithm of 1to 50 odd numbers
Answers
Answered by
0
Using the J programming language:
Generate the integers 1 -> 50, and store them in a.Find the remainders of all 50 integers after dividing each integer by 2.The odd numbers in the list will have a remainder of 1Select all the integers in a that have a remainder of 1, and list them:
a#~2|a=.1+i.50
1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49
<<<<>>>>
“Civilization advances by extending the number of important operations which we can perform without thinking of them.”
― Alfred North Whitehead
Generate the integers 1 -> 50, and store them in a.Find the remainders of all 50 integers after dividing each integer by 2.The odd numbers in the list will have a remainder of 1Select all the integers in a that have a remainder of 1, and list them:
a#~2|a=.1+i.50
1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49
<<<<>>>>
“Civilization advances by extending the number of important operations which we can perform without thinking of them.”
― Alfred North Whitehead
Similar questions