blob: c46a4e64350203e7079b141776e5d194820d525a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
TASK 1: Primorial Numbers
Write a script to generate first 10 Primorial Numbers:
Primorial numbers are those formed by multiplying successive prime numbers.
For example,
P(0) = 1 (1)
P(1) = 2 (1x2)
P(2) = 6 (1x2x3)
P(3) = 30 (1x2x3x5)
MY NOTES: ok, sounds easy, but I'm getting very bored of
"tasks to do with Number Theory and (especially) Primes".
GUEST LANGUAGE: As a bonus, I also had a go at translating ch-1.pl
into C (look in the C directory for that).
Task 2: Kronecker Product
You are given 2 matrices.
Write a script to implement Kronecker Product on the given 2 matrices.
For more information, please refer to the wikipedia page
https://en.wikipedia.org/wiki/Kronecker_product
For example,
A = [ 1 2 ]
[ 3 4 ]
B = [ 5 6 ]
[ 7 8 ]
A x B = [ 1 x [ 5 6 ] 2 x [ 5 6 ] ]
[ [ 7 8 ] [ 7 8 ] ]
[ 3 x [ 5 6 ] 4 x [ 5 6 ] ]
[ [ 7 8 ] [ 7 8 ] ]
= [ 1x5 1x6 2x5 2x6 ]
[ 1x7 1x8 2x7 2x8 ]
[ 3x5 3x6 4x5 4x6 ]
[ 3x7 3x8 4x7 4x8 ]
= [ 5 6 10 12 ]
[ 7 8 14 16 ]
[ 15 18 20 24 ]
[ 21 24 28 32 ]
MY NOTES: Ok, at least it has nothing to do with prime numbers:-)
I note in the Wikipedia page the useful formula:
(A x B)ij = Ai/p,j/q * Bi%p,j%q [where B is of size p x q]
GUEST LANGUAGE: As a bonus, I also had a go at translating ch-2.pl
into C (look in the C directory for that).
|