Posts Tagged ‘Problem’

Python: Factorial Digit Sum

April 25, 2019 Leave a comment

Python: Factorial Digit Sum
Problem 20 @ projectEuler

The Task: The task in projectEuler P20 is to get the sum of the digits in the number Factorial of 100!

Factorial NdefinitionThe factorial of a positive integer n, denoted by n!, is the product of all positive integers less than or equal to n. For example, 10! = 10 × 9 × … × 3 × 2 × 1 = 3628800.

Problem 20 is another easy problem in projectEuler, and we will write two functions to solve it. First one is a Factorial_digit_sum this one will return the factorial of a number. The second function will calculate the sum of all digits in a number N and we will call it sum_of_digits.

Clarification As long as i just start solving or posting my answers to projectEuler portal, i am selecting problems and not going through them in sequence, that’s way my posts are jumps between problems, so if i am posting the code to solve problem 144 (for example) that does’t meaning that i solve all problems before it.

print of solved screen:

The Code:

#Python: Factorial Digit Sum
#Problem No.20 on projectEuler

def Factorial_digit_sum(num):

if (num == 0) :

return 1


return num * Factorial_digit_sum(num-1)

fact =Factorial_digit_sum(100)
print fact,’is the Factorial of {}.’.format(num)

def sum_of_digits(dig):

t = 0

for each in dig:

t = t + int(each)

print ‘\nThe sum of your number is’,t


Follow me on Twitter..


Python: The Factors

April 22, 2019 Leave a comment

Python: Factors of the Number N

This is a short task to get the factors of a given number. The Definition of Factors of N is: The pairs of numbers you multiply to get the N number.

For instance, factors of 15 are 3 and 5, because 3×5 = 15. Some numbers have more than one factorization (more than one way of being factored). For instance, 12 can be factored as 1×12, 2×6, or 3×4

In this task we will write a Python code to ask the user for a number N then will get all the pairs number that if we multiply them will get that N number, we will store the pairs in a array ‘factors’.

The Code:

def factors_of_n(num):



while a <= num:

if num%a==0:

if (num/a,a) not in factors:


a = a + 1

return factors
#Ask the user for a number
num=int(input(“Enter a number: “))

Follow me on Twitter..

My New iPhone 4, a stupid lock phone!!

March 14, 2011 2 comments

I purchased this iPhone 4 from the internet ( there was nothing saying that it’s lock to AT&T and can’t be used out side USA (I wonder where is the customer rights to select a carrier), once i received it i notes that it will not work on Qatar, i am waiting for the unlock solution for OS 4.2.1 BB 3.10.01… No thing till now. For now all i can do is jailbreak it and hope the unlock will be soon released..

New Battery and Grip..

December 14, 2010 4 comments

Last week I had a problem with my New Battery for the Nikon D90 [Read the post]. I went to the Nikon Agent – Qatar, they claimed that there where no warranty on the batteries and the chargers; so they can’t change it or re-fund, I decide to get new one and I ask for the price it increased from 41$ to 45$.. Why??

anyway ..

I search the net [] and I fond a battery grip + remote + 2x batteries for 64$, it takes 10 days to be delivered [international transportation-Aramex] I just received it and here it is.

It’s not bad, nice shape and material, Made In China 🙂 , and the remote was missed!! so no remote..
The batteries are without brand, no name on it I hope it will work fine with me.

[Click the image to enlarge]

Problem with my D90 Battery

November 26, 2010 4 comments

I have two Batteries(EN-EL3e) for my Nikon D90 (A and B), last time i get the empty signal for one of them (A) and i replace it with the other(B), but i forget to re-charge the empty one(A), i can’t remember for how long time. (15 day’s or more).

Yesterday i run out of charge(B) and then i realize that i did not charge my (A) battery so i pluged it and here is what happen:

When i charged it, the light on the charger started blinking 3 times then stops (no lights). i’d change the charger .. keep the battery in the charge for 6 hours..cleaned the connectors on the battery,,. no thing…

Some websites and posts suggest to Freeze it overnight, so I did 12hours in the freezer.. and no thing.. I think it’s dead.

I think the reason is that I let it to be empty without charges, I will get new one next week and make sure that it will not go to ZERO charge level.
[New one cost $41 in Nikon Agent – Qatar]