factors and multiples

9 views
Skip to first unread message

maer...@gmail.com

unread,
Jun 15, 2024, 9:43:00 AMJun 15
to Numbas Users
Hi 

I would like to make a list of numbers containing both all the factors and the first six multiples of a given number. 
In this project: 
i have allready copied your solution to make a list of all the factors, but i would like to add these first 6 multiples so that student have to think whether the randomly chosen number is a factor or a multiple of both of the central number. 

My students (whom I will give a paper copy of these exercises) will have to circle this on their paper. 

How can I do this? 

Sincerely Johan Maertens 

Ben Brawn

unread,
Jun 15, 2024, 10:13:42 AMJun 15
to Numbas Users
I can't access your question but as an example:

if you had a number called n, and you have a list of factors of n called factors_list, you could have another list called multiples_list = map(k->n*k,1..6) or equivalently multiples_list = map(n*k, k,1..6), and then use the + operator to join them, factors_multiples_list = factors_list + multiples_list

note that k here is a dummy variable, but n has to be a defined variable.

Hope that helps
Ben

Reply all
Reply to author
Forward
0 new messages