fork download
  1. #include <stdio.h>
  2.  
  3. void fill_memrey(char* start, char val, int count)
  4. {
  5. char* end = start + count;
  6. char *c= start;
  7. while(c < end)
  8. {
  9. *c++ = val; //this linen is in c++
  10. }
  11. }
  12.  
  13. int get_length_of_strign(char* string)
  14. {
  15. int lenght = 0;
  16. while(*string != 0)
  17. {
  18. lenght++;
  19. string++;
  20. }
  21. return lenght;
  22. }
  23.  
  24. void add_character_to_end_of_string(char* string, char character)
  25. {
  26. string[get_length_of_strign(string)] = character;
  27. }
  28.  
  29. void reverse_string(char* s)
  30. {
  31. int l = get_length_of_strign(s), i;
  32. char c;
  33. for(i = 0; i < l/2; ++i)
  34. {
  35. c = s[i];
  36. s[i] = s[l-i-1];
  37. s[l-i-1] = c;
  38. }
  39. }
  40.  
  41. void printBinary(int n){
  42. int k;
  43. char out[33];
  44. fill_memrey(out, 0, 33);
  45. for(k=0;k<32;k++){
  46. if (n & (1<<k))
  47. add_character_to_end_of_string(out, '1');
  48. else
  49. add_character_to_end_of_string(out, '0');
  50. }
  51. reverse_string(out);
  52. printf("%s", out);
  53. }
  54.  
  55. int main(void) {
  56. unsigned int f = 1, i = 1;
  57. while(1)
  58. {
  59. f *= i;
  60. printf("%02d!: ", i++);
  61. printBinary(f);
  62. printf("\n");
  63. if(f == 0){
  64. break;
  65. }
  66. }
  67. return 0;
  68. }
Success #stdin #stdout 0s 2248KB
stdin
Standard input is empty
stdout
01!: 00000000000000000000000000000001
02!: 00000000000000000000000000000010
03!: 00000000000000000000000000000110
04!: 00000000000000000000000000011000
05!: 00000000000000000000000001111000
06!: 00000000000000000000001011010000
07!: 00000000000000000001001110110000
08!: 00000000000000001001110110000000
09!: 00000000000001011000100110000000
10!: 00000000001101110101111100000000
11!: 00000010011000010001010100000000
12!: 00011100100011001111110000000000
13!: 01110011001010001100110000000000
14!: 01001100001110110010100000000000
15!: 01110111011101110101100000000000
16!: 01110111011101011000000000000000
17!: 11101110110011011000000000000000
18!: 11001010011100110000000000000000
19!: 00000110100010010000000000000000
20!: 10000010101101000000000000000000
21!: 10111000110001000000000000000000
22!: 11100000110110000000000000000000
23!: 00110011011010000000000000000000
24!: 11010001110000000000000000000000
25!: 01111011110000000000000000000000
26!: 10010001100000000000000000000000
27!: 01011000100000000000000000000000
28!: 10101110000000000000000000000000
29!: 10110110000000000000000000000000
30!: 01010100000000000000000000000000
31!: 00101100000000000000000000000000
32!: 10000000000000000000000000000000
33!: 10000000000000000000000000000000
34!: 00000000000000000000000000000000