0% found this document useful (0 votes)
3 views12 pages

Python Program: Factorial & Binary Conversion

Penjelasan logika perintah pengulangan(looping) while dalam bentuk flowchart, dengan contoh cara menghitung nilai faktorial
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views12 pages

Python Program: Factorial & Binary Conversion

Penjelasan logika perintah pengulangan(looping) while dalam bentuk flowchart, dengan contoh cara menghitung nilai faktorial
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd

002 September 30th

2014

Using While in python programming

Membuat Program Menghitung Nilai


Faktorial
Keluaran/Output yang diharapkan
Masukkan Nama Anda : Mahasiswa
Masukkan Nomor Registrasi : 1234567890
Program Menghitung Nilai Faktorial
Masukkan Nilai n : 5
Nama User: Mahasiswa
Nomor Registrasi : 1234567890
5! = 120

Faktorial

n! = n * (n-1) * (n-2) * ... *


(n-n+1)

n! = n * (n-1) * (n-2) * ... * 1

WHILE
The while statement is used for repeated execution as
long as an expression is true:
while_stmt ::= "while" expression ":" suite
"else" ":" suite
This repeatedly tests the expression and, if it is true,
executes the first suite; if the expression is false (which
may be the first time it is tested) the suite of the else
clause, if present, is executed and the loop terminates.
A break statement executed in the first suite
terminates the loop without executing the else clauses
suite. A continue statement executed in the first suite
skips the rest of the suite and goes back to testing the
expression.

n! = n * (n-1) * (n-2) * ... * (nn+1)


5! = 5 * (5-1) * (5-2) * (5-3) * (54)
5! = 5*4*3*2*1

STA
RT
Input
n
Hasil =
1
Selama
Selama 5 1
n 1

n=
5

Hasil =
Hasil = 1* 5
Hasil * n
n=
4

n=nn=5-1
1

Hasil
=5

STA
RT
Input
n
Hasil =
1
Selama
Selama 4 1
5 1

n=
5

Hasil = 1 *
Hasil = 5 * 4
5
n=
n=3
4

n=5n=4-1
1

Hasil
Hasil = 20
=5

STA
RT
Input
n
Hasil =
1
Selama
Selama 3 1
4 1

n=
5

Hasil = 5 *
Hasil = 20 * 3
4
n=
n=2
3

n=4n=3-1
1

Hasil =
Hasil = 60
20

STA
RT
Input
n
Hasil =
1
Selama
Selama 2 1
3 1

n=
5

Hasil =
Hasil = 60 * 2
20*3
n=
n=1
2

n=3n=2-1
1

Hasil =
Hasil = 120
60

STA
RT
Input
n
Hasil =
1
Selama
Selama 1 1
2 1

n=
5

Hasil =
Hasil = 120 * 1
60*2
n=
n=0
1

n=2n=1-1
1

Hasil =
Hasil = 120
120

STA
RT
Input
n
Hasil =
1
Selama
Selama 0 1
1 1
Hasil =
120*1
n=
0

n=11

n=
5

Print
Hasil
END
Hasil =
120

Membuat Program untuk Konversi


Nilai Desimal ke Biner
Keluaran Output yang diharapkan
Masukkan Nama Anda : Mahasiswa
Masukkan Nomor Registrasi : 1234567890
Program Menghitung Nilai Faktorial
Masukkan Nilai Desimal : 123
Nama User: Mahasiswa
Nomor Registrasi : 1234567890
Nilai Biner dari 123 = [1,1,1,1,0,1,1]

You might also like