Divisibility
To find numbers of the form 7aaa that are multiples of 7, I use:
sage:print [a for a in [0..9] if (7000+111*a)%7==0]
[0, 7]
I do not know how to write for 7|7abc.
Thanks.
Hello,
There are various solutions. To generate the list of numbers of the form 7abc, you can use one of:
sage: numbers0 = range(7000,8000)
sage: numbers1 = [7000 + x for x in range(1000)]
sage: numbers2 = [7000 + a*100 + b*10 + c for a in range(10) for b in range(10) for c in range(10)]
Then you can check divisibility the very same way you did. But note that there is a faster way since x is a multiple of 7 if and only if x+7 is a multiple of 7. So once you find one, you only need to go 7 by 7.
Is that ok ?
Vincent
Please start posting anonymously - your entry will be published after you log in or create a new account.
Asked: 10 years ago
Seen: 2,744 times
Last updated: Oct 18 '14
I reedit your question. Please double check that it is all right. It was not very clear.
Thank you for edit.