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)
  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. cout<<'*';
  29. }
  30. if(x==1)
  31. {
  32. cout<<endl;
  33. return;
  34. }
  35. cout<<x<<endl;
  36. return;
  37. }
  38. int main()
  39. {
  40. cin>>a>>b;
  41. for(int i=a;i<=b;i++)
  42. {
  43. fact(i);
  44. }
  45. return 0;
  46. }
Success #stdin #stdout 0.01s 5460KB
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