program main
IMPLICIT none
    INTEGER :: n,copy,dig,d,I,R=0,J
    INTEGER :: NUM(10)
    PRINT *,"enter a number"
    read *,n
    copy=n
    DO I=1,10
    NUM(I)=0
    END DO
    do WHILE(copy>0)
    D=MOD(COPY,10)
    NUM(D+1)=NUM(D+1)+1
    copy=copy/10
    ENDDO
    DO I=10,1,-1
    DO J=1,NUM(I)
    R=R*10+(I-1)
    END DO
     END DO
    PRINT *,"MAXIMUM NUMBER=",R
end program main

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: