Tìm số tự nhiên khi phân tích ra thừa số nguyên tố có nhiều nhân tử nhất

Tìm số tự nhiên khi phân tích ra thừa số nguyên tố có nhiều nhân tử nhất

CHUYÊN ĐỀ CHIA HẾT – SỐ NGUYÊN TỐ

Tìm các số tự nhiên nhỏ hơn hoặc bằng n mà sau khi làm phép phân tích ra thừa số nguyên tố có nhiều nhân tử nhất.

Ví dụ n=9 . Các số có nhiều nhân tử nhất sau khi làm phép phân tích là: 8 = 2.2.2

Program Phan_tich_nguyen_to_2;

Var n, Max, so, i:byte;

Function PTNT(n:integer):byte;

Var i,p:byte;

Begin

    i:=2;

    p:=0;

    While n>1 do if (n mod i)=0 then Begin p:=p+1; n:=n div i end else i:=i+1;

    PTNT:=p;

End;

Procedure PT(n:integer);

Var i:byte;

Begin

    i:=2;

    While n>1 do

    if (n mod i)=0 then

     Begin Write(i,'.'); n:=n div i end else i:=i+1;

End;


Begin

    Write('Nhap so n: ');Readln(n);

    Max:=0;

    For i:= 1 to n do if PTNT(i)>=Max then Begin Max:=PTNT(i); So:=i End;

    Write('So ',So,' co nhieu uoc nhat,',so,' = ');

    PT(So);

    Readln

End.
Bạn thấy bài viết này như thế nào?: 
Average: 2.5 (248 votes)
Ảnh của Tommy Tran

Tommy owner Express Magazine

Drupal Developer having 9+ year experience, implementation and having strong knowledge of technical specifications, workflow development. Ability to perform effectively and efficiently in team and individually. Always enthusiastic and interseted to study new technologies

  • Skype ID: tthanhthuy

Advertisement

 

jobsora

Dich vu khu trung tphcm

Dich vu diet chuot tphcm

Dich vu diet con trung

Quảng Cáo Bài Viết

 
Cách làm việc của Patch Drupal Modules như thế nào trong Drupal 7

Cách làm việc của Patch Drupal Modules như thế nào trong Drupal 7

The first step to find a patch to a contributed Drupal module is to get to that module’s issue queue. 

Why responsive design?

Nói về Rresponsive design là gì

Last fall and winter, the web got very small for me. From early November until late February, nearly all of my internet access was via my iPhone 4S. (I was away from the office dealing with an urgent family health matter.)

How To Get Facebook For Android Phones

How To Get Facebook For Android Phones

It may look like a very simple task; browsing through the Android market to get an app that suits you, but the reality is its not.

Công ty diệt chuột T&C

 

Diet con trung