Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

how many three-digit multiples of 18 have the sum of the digits also equal 18?

//I coded this question in python here is how i got the ans 25:

from numpy import integer
count=0
finalcount=0

for i in range (100,999):
    if i/18 == int(i/18):
        count= count + 1
        n=i
        if sum([int(d) for d in str(n)])==18:
            finalcount= finalcount + 1

print(finalcount)
// answer is 25
Comment

Sum of all the multiples of 3 or 5

const findSum = n => {
  let countArr = []
  
  for(let i = 0; i <= n; i++) if(i % 3 === 0 || i % 5 === 0) countArr.push(i) 
  return countArr.reduce((acc , curr) => acc + curr)
}
console.log(findSum(5))

// With love @kouqhar
Comment

If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. Find the sum of all the multiples of 3 or 5 below 1000.

total_sum = 0
for i in range(1000):
    if (i%3 == 0 or i%5 == 0):
        total_sum = total_sum+i
print total_sum
Comment

PREVIOUS NEXT
Code Example
Python :: setdefault python 
Python :: how to convert int in python 
Python :: reading a dataset in python 
Python :: python how to find the highest even in a list 
Python :: python round 
Python :: add key to dictionairy 
Python :: hash in python 
Python :: array and list in python 
Python :: generator comprehension python 
Python :: precedence in python 
Python :: tri python 
Python :: python call function by string 
Python :: pandas .replace multiple values in column 
Python :: python else syntax 
Python :: how to update image in django 
Python :: circular import error 
Python :: no module named 
Python :: python inherit 
Python :: grab the first letter of each string in an array python 
Python :: python sort list case insensitive 
Python :: tkinter triangle 
Python :: how to clear combobox tkinter 
Python :: python anonymous object 
Python :: call methods from within a class 
Python :: bst in python 
Python :: python convert integer to signed base 2 complement 
Python :: python3 vowels and consonants filter 
Python :: py to flag converter online 
Python :: flask decorator causes views to be named the same thing 
Python :: how to push the element to array in python 
ADD CONTENT
Topic
Content
Source link
Name
3+4 =