Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
número poderoso
program numPoderoso; const M=10; {funcion para ver si es primo solamente} function isPrime(num: integer):boolean; var isIt: boolean; auxDiv: integer; begin isIt := true; auxDiv := 2; while (auxDiv <= num/2) and isIt do begin isIt := (num mod auxDiv) <> 0; auxDiv := auxDiv +1; end; isPrime := isIt; end; function isPowerful(num:integer):boolean; var powerful: boolean; divs: integer; begin {volvemos a inicializar las variables * Notese que el estado por defecto es que si que es poderoso} divs := 2; powerful := true; { vamos comprobando todos los numeros, mirando si * los divisores son primos, y si lo son, comprobamos si su * cuadrado tambien lo es * y es poderoso "mientras no nos digan lo contrario"} while (divs<= num) and powerful do begin if (num mod divs = 0) then begin if (isPrime(divs)) then begin powerful := (num mod (divs*divs) = 0) ; end; end; divs := divs+1; end; if powerful and not (isPrime(num)) then begin isPowerful := True; end else begin isPowerful := False; end; end; var current: integer; numFound: integer; begin write('1 '); numFound := 1; current := 4; {tenemos que encontrar M numeros} while (numFound < M) do begin if (isPowerful(current)) then begin numFound := numFound + 1; writeln(current); end; current := current +1; end; end.
run
|
edit
|
history
|
help
0
png
Expression Tree - Demo2
3
CommandForce3
https://www.facebook.com/gluncev
.heap sort
Chest Interaction Unity
COMPLEX NUMBER
actions and tasks
Enum.IsDefined