fork download
  1. #include<iostream>
  2. using namespace std;
  3. int a,b,idk;
  4. void fact(int x)
  5. {
  6. int ct=0;
  7. cout<<x<<'=';
  8. while(x%2==0||x%3==0||x%5==0)
  9. {
  10. if(x%2==0)
  11. {
  12. x/=2;
  13. cout<<2;
  14. if(x==1)
  15. {
  16. break;
  17. }
  18. }
  19. else if(x%3==0)
  20. {
  21. x/=3;
  22. cout<<3;
  23. if(x==1)
  24. {
  25. break;
  26. }
  27. }
  28. else if(x%5==0)
  29. {
  30. x/=5;
  31. cout<<5;
  32. if(x==1)
  33. {
  34. break;
  35. }
  36. }
  37. cout<<'*';
  38. }
  39. if(x==1)
  40. {
  41. cout<<endl;
  42. return;
  43. }
  44. cout<<x<<endl;
  45. return;
  46. }
  47. int main()
  48. {
  49. cin>>a>>b;
  50. for(int i=a;i<=b;i++)
  51. {
  52. fact(i);
  53. }
  54. return 0;
  55. }
Success #stdin #stdout 0.01s 5544KB
stdin
3 100
stdout
3=3
4=2*2
5=5
6=2*3
7=7
8=2*2*2
9=3*3
10=2*5
11=11
12=2*2*3
13=13
14=2*7
15=3*5
16=2*2*2*2
17=17
18=2*3*3
19=19
20=2*2*5
21=3*7
22=2*11
23=23
24=2*2*2*3
25=5*5
26=2*13
27=3*3*3
28=2*2*7
29=29
30=2*3*5
31=31
32=2*2*2*2*2
33=3*11
34=2*17
35=5*7
36=2*2*3*3
37=37
38=2*19
39=3*13
40=2*2*2*5
41=41
42=2*3*7
43=43
44=2*2*11
45=3*3*5
46=2*23
47=47
48=2*2*2*2*3
49=49
50=2*5*5
51=3*17
52=2*2*13
53=53
54=2*3*3*3
55=5*11
56=2*2*2*7
57=3*19
58=2*29
59=59
60=2*2*3*5
61=61
62=2*31
63=3*3*7
64=2*2*2*2*2*2
65=5*13
66=2*3*11
67=67
68=2*2*17
69=3*23
70=2*5*7
71=71
72=2*2*2*3*3
73=73
74=2*37
75=3*5*5
76=2*2*19
77=77
78=2*3*13
79=79
80=2*2*2*2*5
81=3*3*3*3
82=2*41
83=83
84=2*2*3*7
85=5*17
86=2*43
87=3*29
88=2*2*2*11
89=89
90=2*3*3*5
91=91
92=2*2*23
93=3*31
94=2*47
95=5*19
96=2*2*2*2*2*3
97=97
98=2*49
99=3*3*11
100=2*2*5*5