Skip to content

Commit 62c7e7d

Browse files
committed
Added P007-P020
1 parent 21658ac commit 62c7e7d

File tree

16 files changed

+361
-3
lines changed

16 files changed

+361
-3
lines changed

problems/P005/README.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
2-
# Problem 004
1+
# Problem 005
32
Write a program accepts two integer values and a math operator
43
and depending on the operator calculate the result of the operaiton.
54
Operator can be one of + - / * characters.

problems/P006/README.md

+23-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,24 @@
11
# Problem 006
2-
Write a program for problem 006 - detailed description
2+
Write a program which gets an integer N and calculates the
3+
sum of all numbers from 1 to N.
4+
5+
1 <= N <= 1000
6+
7+
# Persian Description
8+
برنامه ای بنویسید که ابتدا یک عدد از ورودی دریافت کند سپس حاصل جمع اعداد یک تا آن تا عدد را محاسبه و چاپ کند. ماکزیمم ورودی: ۱۰۰۰
9+
10+
# Sample Input/Output
11+
12+
## Input:
13+
```
14+
3
15+
5
16+
100
17+
```
18+
19+
## Output:
20+
```
21+
6
22+
15
23+
5050
24+
```

problems/P007/README.md

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Problem 007
2+
Write a program which gets an integer N and prints all numbers
3+
less than N and divisible by 5.
4+
5+
# Persian Description
6+
برنامه ای بنویسید که یک عدد از ورودی دریافت کرده و تمام اعداد بزرگتر از یک و کوچکتر از آن و بخش پذیر بر ۵ را چاپ کند
7+
8+
# Sample Input/Output
9+
10+
## Input:
11+
```
12+
32
13+
```
14+
15+
## Output:
16+
```
17+
5
18+
10
19+
15
20+
20
21+
25
22+
30
23+
```

problems/P008/README.md

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Problem 008
2+
Write a program to calculate Factorial of input numbers.
3+
Factorial of N is the product of all numbers less than equal to N.
4+
5+
# Persian Description
6+
برنامه ای بنویسید که فاکتوریل n را حساب کند. فاکتوریل حاصل ضرب تمام اعداد کوچکتر و مساوی n در همدیگر است
7+
8+
# Sample Input/Output
9+
10+
## Input:
11+
```
12+
5
13+
6
14+
```
15+
16+
## Output:
17+
```
18+
120
19+
720
20+
```

problems/P009/README.md

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Problem 009
2+
Write a program to calculate all primes numbers less than N.
3+
A prime number is only divisble by itself and 1.
4+
5+
# Persian Description
6+
برنامه ای بنویسید که اعداد اول کوچکتر از n را چاپ کند
7+
عددی اول است که به غیر یک و خودش بر عدد دیگری بخش پذیر نباشد
8+
9+
# Sample Input/Output
10+
11+
## Input:
12+
```
13+
20
14+
```
15+
16+
## Output:
17+
```
18+
2
19+
3
20+
5
21+
7
22+
11
23+
13
24+
17
25+
19
26+
```

problems/P010/README.md

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Problem 010
2+
Write a program to calculate n-primorial.
3+
N-Primorial is the product of all prime numbers less than or equal to N.
4+
5+
# Persian Description
6+
برنامه ای بنویسید که n-primorial را حساب کند.
7+
این عدد حاصلضرب تمام اعداد اول کوچکتر از عدد n است
8+
9+
# Sample Input/Output
10+
11+
## Input:
12+
```
13+
10
14+
```
15+
16+
## Output:
17+
```
18+
210
19+
```

problems/P011/README.md

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Problem 011
2+
Write a program to calculate the sequence of Fibonacci numbers.
3+
Write the program in two different ways:
4+
- Recursive (also with memoizing the calcualted values)
5+
- Non-Recursive
6+
7+
# Persian Description
8+
برنامه ای بنویسید که n را از ورودی دریافت کرده و اعضای دنباله فیبوناچی کوچکتر از n را تولید کند.
9+
10+
برنامه را به دو روش بازگشتی (با ذخیره مقادیر محاسبه شده قبلی جهت جلوگیری از محاسبه‌ی مجدد) و غیربازگشتی بنویسید
11+
12+
# Sample Input/Output
13+
14+
## Input:
15+
```
16+
25
17+
```
18+
19+
## Output:
20+
```
21+
1
22+
1
23+
2
24+
3
25+
5
26+
8
27+
13
28+
21
29+
```

problems/P012/README.md

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Problem 012
2+
Write a program to get a list of integers, e.g N, for each one
3+
prints N-th prime number.
4+
5+
# Persian Description
6+
برنامه ای بنویسید که عدد n را از ورودی بگیرد و n مین عدد اول را چاپ کند.
7+
8+
# Sample Input/Output
9+
10+
## Input:
11+
```
12+
4
13+
1000
14+
```
15+
16+
## Output:
17+
```
18+
7
19+
7919
20+
```

problems/P013/README.md

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Problem 013
2+
Write a program to calculate the prime factors of input integers.
3+
4+
# Persian Description
5+
برنامه ای بنویسید که یک عدد از ورودی دریافت کرده و فاکتورهای اول آن را چاپ کند
6+
7+
# Sample Input/Output
8+
9+
## Input:
10+
```
11+
4
12+
42
13+
88
14+
39
15+
```
16+
17+
## Output:
18+
```
19+
Prime factors of 4 are [2, 2]
20+
Prime factors of 42 are [2, 3, 7]
21+
Prime factors of 88 are [2, 2, 2, 11]
22+
Prime factors of 39 are [3, 13]
23+
```

problems/P014/README.md

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Problem 014
2+
Write a program including a function named 'merge'
3+
which merges (concatenates) two input lists.
4+
5+
First line of input is `n` then `n` lines of numbers follows.
6+
Next line of input is `m` then `m` lines of numbers follows.
7+
8+
# Persian Description
9+
برنامه ای بنویسید شامل یک تابع به نام merge که دو لیست را از ورودی بگیرد و با هم ادغام کند.
10+
11+
برنامه ابتدا یک ورودی میگیرد به نام n سپس به تعداد n ورودی دریافت می کند برای لیست اول
12+
مجددا یک ورودی دریافت کند به نام m و سپس m ورودی دریافت کند برای لیست دوم
13+
14+
# Sample Input/Output
15+
16+
## Input:
17+
```
18+
2
19+
Ali
20+
Hassan
21+
3
22+
Reza
23+
Milad
24+
Mohsen
25+
```
26+
27+
## Output:
28+
```
29+
[Ali, Hassan, Reza, Milad, Mohsen]
30+
```

problems/P015/README.md

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Problem 015
2+
Write a program including a function named 'sumlist'
3+
which calculates the sum of all numbers in the given list.
4+
5+
First line of input is `n` then `n` lines of numbers follows.
6+
7+
# Persian Description
8+
برنامه ای بنویسید شامل یک تابع به نام sumlist که مجموع اعداد لیست را محاسبه کند
9+
10+
ورودی شامل یک عدد n و سپس n عدد برای اعضای لیست.
11+
12+
# Sample Input/Output
13+
14+
## Input:
15+
```
16+
4
17+
8
18+
6
19+
2
20+
10
21+
```
22+
23+
## Output:
24+
```
25+
30
26+
```

problems/P016/README.md

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Problem 016
2+
Write a program which generates output similar to sample output.
3+
4+
# Persian Description
5+
برنامه ای بنویسید که یک عدد از ورودی دریافت کرده و خروجی زیر را چاپ کند
6+
7+
# Sample Input/Output
8+
9+
## Input:
10+
```
11+
4
12+
7
13+
```
14+
15+
## Output:
16+
```
17+
@@@@
18+
@@@
19+
@@
20+
@
21+
22+
@@@@@@@
23+
@@@@@@
24+
@@@@@
25+
@@@@
26+
@@@
27+
@@
28+
@
29+
```

problems/P017/README.md

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Problem 017
2+
Write a program which generates output similar to sample output.
3+
4+
# Persian Description
5+
برنامه ای بنویسید که یک ورودی دریافت کرده و خروجی مشابه نمونه را چاپ کند
6+
7+
# Sample Input/Output
8+
9+
## Input:
10+
```
11+
5
12+
3
13+
```
14+
15+
## Output:
16+
```
17+
+++++
18+
++++0
19+
+++00
20+
++000
21+
+0000
22+
00000
23+
24+
+++
25+
++0
26+
+00
27+
000
28+
```

problems/P018/README.md

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Problem 018
2+
Write a program which prints all Twin-Primes less than input number.
3+
4+
# Persian Description
5+
برنامه ای بنویسید که یک عدد از ورودی دریافت کرده و تمام جفت اعداد اول دوقلوی (Twin Primes) کوچکتر از آن را چاپ کند
6+
7+
# Sample Input/Output
8+
9+
## Input:
10+
```
11+
20
12+
```
13+
14+
## Output:
15+
```
16+
3, 5
17+
5, 7,
18+
11,13
19+
17,19
20+
```

problems/P019/README.md

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Problem 019
2+
Write a program which prints the Pascal-Khayam triangle up to line N.
3+
4+
# Persian Description
5+
برنامه ای بنویسید که مثلث پاسکال خیام را تا سطر N چاپ کند
6+
7+
# Sample Input/Output
8+
9+
## Input:
10+
```
11+
5
12+
```
13+
14+
## Output:
15+
```
16+
1
17+
1 1
18+
1 2 1
19+
1 3 3 1
20+
1 4 6 4 1
21+
```

problems/P020/README.md

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Problem 020
2+
Write a program which prints the written format of input numbers.
3+
1 <= N <= 10
4+
5+
# Persian Description
6+
برنامه ای بنویسید که معادل نوشتاری عدد ورودی را با استفاده از دیکشنری چاپ کند.
7+
ورودی بین ۱ تا ۱۰
8+
9+
# Sample Input/Output
10+
11+
## Input:
12+
```
13+
1
14+
3
15+
7
16+
```
17+
18+
## Output:
19+
```
20+
One
21+
Three
22+
Seven
23+
```

0 commit comments

Comments
 (0)