Python Forum
Calculate the multiple of a number
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Calculate the multiple of a number
#2
The test for multiples is odd. Multiples of 15 will be 15, 30, 45, 60, …. There is no reason for me to test 1, 2, ...14, 15 etc. Reversing your logic to generate multiples and stop when the multiple is out of range would be a lot more efficient.

But that is not what you are asking. I'm not exactly sure what you are asking. Do you want the multiples printed out or not? Or do you want to return the multiples, say in a list, instead of printing them out? Do you want the program to return [15, 30, 45, 60] instead of 4?
Reply


Messages In This Thread
Calculate the multiple of a number - by pythonuser1 - Mar-24-2020, 10:30 PM
RE: Calculate the multiple of a number - by deanhystad - Mar-25-2020, 04:31 AM
RE: Calculate the multiple of a number - by Fre3k - Mar-25-2020, 10:16 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  calculate the 10001st prime number topologh 7 6,519 Oct-05-2020, 07:41 PM
Last Post: deanhystad
  Divide a number - Multiple levels - Sum of all numbers equal to input number pythoneer 17 9,267 Apr-20-2018, 04:07 AM
Last Post: pythoneer

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020