Advertisement
sahadat49

number theory

Feb 16th, 2019
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1.  
  2.  
  3. #include<bits/stdc++.h>
  4. using namespace std;
  5. int main()
  6. {
  7. int a[]= {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97};
  8. int cnt[100];
  9. int n,x,i,j;
  10. while(scanf("%d",&n)){
  11. if(n==0)break;
  12. memset(cnt,0,sizeof cnt);
  13. for(i=2;i<=n;i++){
  14. x=i;
  15. for(j=0;j<25;j++){
  16. int count=0;
  17. while(x%a[j]==0){
  18. count++;
  19. x/=a[j];
  20. }
  21. cnt[j]+=count;
  22. }
  23. }
  24. for(i=0;a[i]<=n;i++){
  25. if(cnt[i]==0)continue;
  26. printf("%d ",cnt[i]);
  27. }
  28. printf("\n");
  29. }
  30. return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement