how to get all the possible combinations for 4 digits from a 5 digit number.

i need a pair that has both 5 digits and four digits. their sum must be equal to a five digit user input.

i.e.

user input : 14690

output:

14690 has pairs 12345 + 2345

2345 came from 12345

lets say that x = 12345 and y =2345

besides y == x%10000

other formula can i have since if i use % and / i will have a lot of declarations

i need a pair that has both 5 digits and four digits. their sum must be equal to a five digit user input.

i.e.

user input : 14690

output:

14690 has pairs 12345 + 2345

2345 came from 12345

lets say that x = 12345 and y =2345

besides y == x%10000

other formula can i have since if i use % and / i will have a lot of declarations

Last edited on

-ask for user input num

-if num < 10000 or >= 100000, ask again

-loop i from 10000 to num - 1000 and check if num - i is between 1000 and 9999, and print i and num - i if so.

-if num < 10000 or >= 100000, ask again

-loop i from 10000 to num - 1000 and check if num - i is between 1000 and 9999, and print i and num - i if so.

Last edited on

Topic archived. No new replies allowed.