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

 
Android Phone Extension With Evernote Application

Android Phone Extension With Evernote Application

Once you have Evernote on your Android phone, you will not need to take constant notes or right things on your palm to keep record of happenings or ideas

 Microsoft sắp tung ra hệ thống điện toán đám mây nền tảng Windows

Microsoft sắp tung ra hệ thống điện toán đám mây nền tảng Windows

Cùng với việc công bố phiên bản Windows Server 2012 tại hội thảo các đối tác toàn cầu của Microsoft diễn ra ở Canada, công ty còn tiết lộ một bộ ba dịch vụ mới nhằm tận dụng ưu thế của các công cụ điện toán đám mây có trong phần mềm này.

 

Lucidly Drupal: Setting up Ubuntu 10.4 Lucid LAMP stack for your Drupal site

Lucidly Drupal: Setting up Ubuntu 10.4 Lucid LAMP stack for your Drupal site

We're frequently setting up servers for development, for staging, for production. I've lately preferred the Debian flavor of Linux, but up until now that had been something of a problem because Debian and Ubuntu did not include the higher-quality php5-gd library, which meant that you either had to compile your own PHP, pull from an alternative source host, or cope with substandard image resizing with limited processing features.

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

 

Diet con trung