You are on page 1of 10

Hàm…

CHỮA BÀI TẬP


…HÀM…
Bài phân tích thừa số nguyên tố
#include <iostream>
#include <cmath>
using namespace std; int main() {
long long n;
cin >> n;
bool x = true;
for (long long i = 2; i <= sqrt(n); i++) {
if (n % i == 0) {
int ans = 0;
while (n % i == 0) {
++ans;
n /= i;
}
if (!x) {
cout << " * ";
}
cout << i << "^" << ans; x = false;
}

} if (n > 1) { if (!x) {

#include<bits/stdc++.h> using namespace std; void pttsnt(int64_t n)


{ for(int64_t i=2 ;i <= sqrt(n) ;i++) { if(n % i==0) { int64_t dem =0; while( n%i ==0) { dem++; n/=i; } cout << i <<
"^" << dem; if( n!=1) cout << " * "; } } if(n !=1) cout << n << "^1"; } int main(){ int64_t n;cin>>n; pttsnt(n); }

BÀI 14: so thuan nghich_loc phat


BUỔI HỌC (14/06/2023)
Quy tắc:
- Xác định tên hàm: ( những đối số )

- Hàm void ( không cần return )


ÔN TẬP
Từ khóa Break

Từ khóa continue:
Phi euler

You might also like