c - Possible Combination that could be made with the same number -


i'm working on c program calculate number of possibilities made same number. example: 444 should produce 6 number of possibilities (it counts 4,4,4,44,44,444). think use loop if statement in solve problem. thank you

it's unclear asking, if understand correctly there simple formula that

given number of n caracteres, have:

  • 1 subset of size n
  • 2 subsets of size n-1
  • ...
  • n subset of size 1

so re computing sum of in 1..n is

n*(n+1)/2 

in exemple 444 of size 3, , 3*(3+1)/2 = 6


Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -