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!=1)
  9. {
  10. if(x%2==0)
  11. {
  12. x/=2;
  13. cout<<2;
  14. }
  15. else if(x%3==0)
  16. {
  17. x/=3;
  18. cout<<3;
  19. }
  20. cout<<'*';
  21. }
  22. if(x==1)
  23. {
  24. cout<<endl;
  25. return;
  26. }
  27. cout<<x<<endl;
  28. return;
  29. }
  30. int main()
  31. {
  32. cin>>a>>b;
  33. for(int i=a;i<=b;i++)
  34. {
  35. fact(i);
  36. }
  37. return 0;
  38. }
Success #stdin #stdout 0.01s 5432KB
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