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 5476KB
stdin
3 10
stdout
3=3
4=2*2
5=5
6=2*3
7=7
8=2*2*2
9=3*3
10=2*5