+ 2
Plz can someone help me ??
Write a program in python and an algorithm with algobox named SOM_CHIFFRES, which allows to determine the sum of the digits of a given integer X. Example: for N = 26418, we will have 2 + 6 + 4 + 1 + 8 = 21) Change the program to test if x divisible by 3 (algo and pg) in the same folder. Rq: a number is divisible by 3 if the sum of these digits and divisible by 3
14 odpowiedzi
+ 4
If you break it down, this task is actually quite simple. You try to write this program. If something isn’t working, ask for help. We won’t do your work for you, only point you in the right direction
+ 4
You don’t need to be smart in mathematics. If you’re struggling with this, you really need to pay attention in class and make sure you understand what your professor is saying. Ask questions if you need to, just be sure to understand
+ 1
Well I'll give you what I reached and can you plz fix it for me
+ 1
Absolutely. As long as you attempt and give it your all, I have no problem helping you
0
-use // operator to do integer division by 10, to remove last digit of a number
-use n%10 to take last out last digit on integer n.
-make a loop while n is not equal to 0, in each iteration take out last digit of n and add it to some variable sum, and remove last digit from n(modify value of n).
-after loop, check value of sum%3==0.
0
It's just 4 lines
0
I have an exam tomorrow and I haven't found a solution for this
0
Thx
- 1
I know but I'm not smart in mathematics
- 1
a=int(input(donner votre:))
S=0
b=0
While
b=a%10//10
Print(b)
- 1
I mean
a=int(input(donner votre:))
S=0
While
S=a%10//10
Print(b)
- 1
def divi3(x):
a=0
for i in str(x):
a=a+int(i)
if not a % 3:
return 1
else:
return 0
divi3(4536)