September 2017 Update
This commit is contained in:
parent
bba7bfd280
commit
ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions
39
Task/Van-der-Corput-sequence/Bc/van-der-corput-sequence.bc
Normal file
39
Task/Van-der-Corput-sequence/Bc/van-der-corput-sequence.bc
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* Return the _n_th term of the van der Corput sequence.
|
||||
* Uses the current _ibase_.
|
||||
*/
|
||||
define v(n) {
|
||||
auto c, r, s
|
||||
|
||||
s = scale
|
||||
scale = 0 /* to use integer division */
|
||||
|
||||
/*
|
||||
* c = count digits of n
|
||||
* r = reverse the digits of n
|
||||
*/
|
||||
for (0; n != 0; n /= 10) {
|
||||
c += 1
|
||||
r = (10 * r) + (n % 10)
|
||||
}
|
||||
|
||||
/* move radix point to left of digits */
|
||||
scale = length(r) + 6
|
||||
r /= 10 ^ c
|
||||
|
||||
scale = s
|
||||
return r
|
||||
}
|
||||
|
||||
t = 10
|
||||
for (b = 2; b <= 4; b++) {
|
||||
"base "; b
|
||||
obase = b
|
||||
for (i = 0; i < 10; i++) {
|
||||
ibase = b
|
||||
" "; v(i)
|
||||
ibase = t
|
||||
}
|
||||
obase = t
|
||||
}
|
||||
quit
|
||||
Loading…
Add table
Add a link
Reference in a new issue