I'm trying to figure out how to create an array with $n$ elements in it and then fill it with numbers than I input from the keyboard.
I understand how to do this logically from some experience I have in programming, but I don't know what command to use.
I know that I'd need to create an array with a length of $n$, and then most likely populate it using a For
loop.
However, I have no clue as to what commands I need to use in the generation of the array, nor do I understand how to access an element given its index in the array.
EDIT
Essentially, I'm supposed to begin by taking an input n, which is an integer. Then I need to input n more numbers, by keyboard(which I assume is the same as input during execution, so I'll take a look at the Input command again), however I'm then supposed to calculate how many numbers the inputted number is divisible by. This made me think that I'm taking in an array of numbers, then going from 0 to n, calculating how many numbers the element is divisible by, and adding them into a variable. I'm sorry if this doesn't make much sense, I'm struggling to translate some of these terms into English
yourarray = {{first, row, values}, {second, row, values}, ...}
. If you mean that you have to take user input during execution, you could look atInput
. A very brute force approach could beTable[Input[], numRows, numColumns]
where you substitute the actual number of rows and columns you want in the array. $\endgroup$Divisors
in the documentation as well. The number of integer divisors would then be given byLength[Divisors[yourNumber]]
for each one of the numbers you want. Also, in your description I do not understand what the "other" numbers are for, i.e. 1) you ask the user for a number; 2) you calculate the number of divisors for that number; 3) ....? What is your stopping condition? I.e. when do you stop accepting numbers? $\endgroup$