Finding Greatest Common Divisor using LuaLatexAccessing to .log messages from LuaTeX. Is it possible?LuaLaTeX for dummies: basic directlua useHelp integrating some LUA code into a Luatex document?LuaLaTeX: compilation fails when sorting text using luacodeLuaLaTeX — Attempt to index global 'luatexbase'LuaLaTeX: Calculate length in LuaMy first luaLaTeX exampleLoad fields from JSON file using LuaLatexHow to use lua code from external file in lualatex?Arithmetics in LuaLaTeX
Does switching on an old games console without a cartridge damage it?
Why are Oscar, India, and X-Ray (O, I, and X) not used as taxiway identifiers?
Substitute dried pig's blood for fresh
When will the last unambiguous evidence of mankind disappear?
Longest to Shortest tractates of Yerushalmi by daf
Can "Taking algebraic closure" be made into a functor?
How to pass array of values in lualatex?
What do Unicorns want?
Oriented vector bundle with odd-dimensional fibers
Pass USB 3.0 connection through D-SUB connector
MITM on HTTPS traffic in Kazakhstan 2019
Why does the salt in the oceans not sink to the bottom?
Why do we need an estimator to be consistent?
Considerations when providing money to only one child out of two
What kind of vegetable has pink and white concentric rings?
Langton's Ant Periodic Behavior
Acoustic guitar chords' positions vs those of a Bass guitar
Would using carbon dioxide as fuel work to reduce the greenhouse effect?
Found more old paper shares from broken up companies
Calculating Fibonacci sequence in several different ways
Quickest way to move a line in a text file before another line in a text file?
Why is there an extra "t" in Lemmatization?
You have no, but can try for yes
How can I show that the speed of light in vacuum is the same in all reference frames?
Finding Greatest Common Divisor using LuaLatex
Accessing to .log messages from LuaTeX. Is it possible?LuaLaTeX for dummies: basic directlua useHelp integrating some LUA code into a Luatex document?LuaLaTeX: compilation fails when sorting text using luacodeLuaLaTeX — Attempt to index global 'luatexbase'LuaLaTeX: Calculate length in LuaMy first luaLaTeX exampleLoad fields from JSON file using LuaLatexHow to use lua code from external file in lualatex?Arithmetics in LuaLaTeX
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
Here is my code to find Greatest Common Divisor of two positive integers.
documentclassarticle
usepackageluacode
beginluacode
function gcd(a,b)
if b ~= 0 then
return gcd(b, a % b)
else
return math.abs(a)
end
end
endluacode
newcommandfindgcd[2]directluatex.sprint(gcd(#1,#2))
begindocument
findgcd5,10
enddocument
It throws error. The expected output is simply gcd of 5 and 10. Is % sign in lua code causing the error?
luatex lua luacode directlua
add a comment |
Here is my code to find Greatest Common Divisor of two positive integers.
documentclassarticle
usepackageluacode
beginluacode
function gcd(a,b)
if b ~= 0 then
return gcd(b, a % b)
else
return math.abs(a)
end
end
endluacode
newcommandfindgcd[2]directluatex.sprint(gcd(#1,#2))
begindocument
findgcd5,10
enddocument
It throws error. The expected output is simply gcd of 5 and 10. Is % sign in lua code causing the error?
luatex lua luacode directlua
add a comment |
Here is my code to find Greatest Common Divisor of two positive integers.
documentclassarticle
usepackageluacode
beginluacode
function gcd(a,b)
if b ~= 0 then
return gcd(b, a % b)
else
return math.abs(a)
end
end
endluacode
newcommandfindgcd[2]directluatex.sprint(gcd(#1,#2))
begindocument
findgcd5,10
enddocument
It throws error. The expected output is simply gcd of 5 and 10. Is % sign in lua code causing the error?
luatex lua luacode directlua
Here is my code to find Greatest Common Divisor of two positive integers.
documentclassarticle
usepackageluacode
beginluacode
function gcd(a,b)
if b ~= 0 then
return gcd(b, a % b)
else
return math.abs(a)
end
end
endluacode
newcommandfindgcd[2]directluatex.sprint(gcd(#1,#2))
begindocument
findgcd5,10
enddocument
It throws error. The expected output is simply gcd of 5 and 10. Is % sign in lua code causing the error?
luatex lua luacode directlua
luatex lua luacode directlua
asked 11 hours ago
user61681user61681
3891 silver badge9 bronze badges
3891 silver badge9 bronze badges
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
You have defined findgcd with two arguments, but you only supply one:
findgcd510
will work.
If you want the syntax findgcd5,10, then declare it:
documentclassarticle
usepackageluacode
beginluacode
function gcd(a,b)
if b ~= 0 then
return gcd(b, a % b)
else
return math.abs(a)
end
end
endluacode
newcommandfindgcd[1]directluatex.sprint(gcd(#1))
begindocument
findgcd5,10
enddocument
Here's a simple package code, save as gcd.sty:
ProvidesPackagegcd[2019/07/22]
RequirePackageluacode
beginluacode
function gcd(a,b)
if b ~= 0 then
return gcd(b, a % b)
else
return math.abs(a)
end
end
endluacode
newcommandfindgcd[2]directluatex.sprint(gcd(#1,#2))
endinput
Now your document, as soon as gcd.sty is in a directory read by the TeX engines, can be
documentclassarticle
usepackagegcd
begindocument
findgcd510
enddocument
Is it possible to store this function as a package? I mean something like this. usepackagegcd and with this package findgcd command will be available to use it anywhere in document.
– user61681
10 hours ago
@user61681 Yes, write a package and upload it to CTAN.
– egreg
10 hours ago
Could you share some resources? How to write package for this type of lua functions?
– user61681
10 hours ago
1
Thanks for your detailed help. You are great...! Just one last query, though it is out of scope here. I am trying to learn how to write latex macros (own commands, environments etc.). I couldn't find any resources for that. I have programming background but still find it difficult to learn latex programming. Could you share some resources if you know? Thanks again.
– user61681
9 hours ago
@user61681 It's best if they're documented.
– egreg
9 hours ago
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "85"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f500932%2ffinding-greatest-common-divisor-using-lualatex%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You have defined findgcd with two arguments, but you only supply one:
findgcd510
will work.
If you want the syntax findgcd5,10, then declare it:
documentclassarticle
usepackageluacode
beginluacode
function gcd(a,b)
if b ~= 0 then
return gcd(b, a % b)
else
return math.abs(a)
end
end
endluacode
newcommandfindgcd[1]directluatex.sprint(gcd(#1))
begindocument
findgcd5,10
enddocument
Here's a simple package code, save as gcd.sty:
ProvidesPackagegcd[2019/07/22]
RequirePackageluacode
beginluacode
function gcd(a,b)
if b ~= 0 then
return gcd(b, a % b)
else
return math.abs(a)
end
end
endluacode
newcommandfindgcd[2]directluatex.sprint(gcd(#1,#2))
endinput
Now your document, as soon as gcd.sty is in a directory read by the TeX engines, can be
documentclassarticle
usepackagegcd
begindocument
findgcd510
enddocument
Is it possible to store this function as a package? I mean something like this. usepackagegcd and with this package findgcd command will be available to use it anywhere in document.
– user61681
10 hours ago
@user61681 Yes, write a package and upload it to CTAN.
– egreg
10 hours ago
Could you share some resources? How to write package for this type of lua functions?
– user61681
10 hours ago
1
Thanks for your detailed help. You are great...! Just one last query, though it is out of scope here. I am trying to learn how to write latex macros (own commands, environments etc.). I couldn't find any resources for that. I have programming background but still find it difficult to learn latex programming. Could you share some resources if you know? Thanks again.
– user61681
9 hours ago
@user61681 It's best if they're documented.
– egreg
9 hours ago
add a comment |
You have defined findgcd with two arguments, but you only supply one:
findgcd510
will work.
If you want the syntax findgcd5,10, then declare it:
documentclassarticle
usepackageluacode
beginluacode
function gcd(a,b)
if b ~= 0 then
return gcd(b, a % b)
else
return math.abs(a)
end
end
endluacode
newcommandfindgcd[1]directluatex.sprint(gcd(#1))
begindocument
findgcd5,10
enddocument
Here's a simple package code, save as gcd.sty:
ProvidesPackagegcd[2019/07/22]
RequirePackageluacode
beginluacode
function gcd(a,b)
if b ~= 0 then
return gcd(b, a % b)
else
return math.abs(a)
end
end
endluacode
newcommandfindgcd[2]directluatex.sprint(gcd(#1,#2))
endinput
Now your document, as soon as gcd.sty is in a directory read by the TeX engines, can be
documentclassarticle
usepackagegcd
begindocument
findgcd510
enddocument
Is it possible to store this function as a package? I mean something like this. usepackagegcd and with this package findgcd command will be available to use it anywhere in document.
– user61681
10 hours ago
@user61681 Yes, write a package and upload it to CTAN.
– egreg
10 hours ago
Could you share some resources? How to write package for this type of lua functions?
– user61681
10 hours ago
1
Thanks for your detailed help. You are great...! Just one last query, though it is out of scope here. I am trying to learn how to write latex macros (own commands, environments etc.). I couldn't find any resources for that. I have programming background but still find it difficult to learn latex programming. Could you share some resources if you know? Thanks again.
– user61681
9 hours ago
@user61681 It's best if they're documented.
– egreg
9 hours ago
add a comment |
You have defined findgcd with two arguments, but you only supply one:
findgcd510
will work.
If you want the syntax findgcd5,10, then declare it:
documentclassarticle
usepackageluacode
beginluacode
function gcd(a,b)
if b ~= 0 then
return gcd(b, a % b)
else
return math.abs(a)
end
end
endluacode
newcommandfindgcd[1]directluatex.sprint(gcd(#1))
begindocument
findgcd5,10
enddocument
Here's a simple package code, save as gcd.sty:
ProvidesPackagegcd[2019/07/22]
RequirePackageluacode
beginluacode
function gcd(a,b)
if b ~= 0 then
return gcd(b, a % b)
else
return math.abs(a)
end
end
endluacode
newcommandfindgcd[2]directluatex.sprint(gcd(#1,#2))
endinput
Now your document, as soon as gcd.sty is in a directory read by the TeX engines, can be
documentclassarticle
usepackagegcd
begindocument
findgcd510
enddocument
You have defined findgcd with two arguments, but you only supply one:
findgcd510
will work.
If you want the syntax findgcd5,10, then declare it:
documentclassarticle
usepackageluacode
beginluacode
function gcd(a,b)
if b ~= 0 then
return gcd(b, a % b)
else
return math.abs(a)
end
end
endluacode
newcommandfindgcd[1]directluatex.sprint(gcd(#1))
begindocument
findgcd5,10
enddocument
Here's a simple package code, save as gcd.sty:
ProvidesPackagegcd[2019/07/22]
RequirePackageluacode
beginluacode
function gcd(a,b)
if b ~= 0 then
return gcd(b, a % b)
else
return math.abs(a)
end
end
endluacode
newcommandfindgcd[2]directluatex.sprint(gcd(#1,#2))
endinput
Now your document, as soon as gcd.sty is in a directory read by the TeX engines, can be
documentclassarticle
usepackagegcd
begindocument
findgcd510
enddocument
edited 10 hours ago
answered 10 hours ago
egregegreg
756k90 gold badges1979 silver badges3325 bronze badges
756k90 gold badges1979 silver badges3325 bronze badges
Is it possible to store this function as a package? I mean something like this. usepackagegcd and with this package findgcd command will be available to use it anywhere in document.
– user61681
10 hours ago
@user61681 Yes, write a package and upload it to CTAN.
– egreg
10 hours ago
Could you share some resources? How to write package for this type of lua functions?
– user61681
10 hours ago
1
Thanks for your detailed help. You are great...! Just one last query, though it is out of scope here. I am trying to learn how to write latex macros (own commands, environments etc.). I couldn't find any resources for that. I have programming background but still find it difficult to learn latex programming. Could you share some resources if you know? Thanks again.
– user61681
9 hours ago
@user61681 It's best if they're documented.
– egreg
9 hours ago
add a comment |
Is it possible to store this function as a package? I mean something like this. usepackagegcd and with this package findgcd command will be available to use it anywhere in document.
– user61681
10 hours ago
@user61681 Yes, write a package and upload it to CTAN.
– egreg
10 hours ago
Could you share some resources? How to write package for this type of lua functions?
– user61681
10 hours ago
1
Thanks for your detailed help. You are great...! Just one last query, though it is out of scope here. I am trying to learn how to write latex macros (own commands, environments etc.). I couldn't find any resources for that. I have programming background but still find it difficult to learn latex programming. Could you share some resources if you know? Thanks again.
– user61681
9 hours ago
@user61681 It's best if they're documented.
– egreg
9 hours ago
Is it possible to store this function as a package? I mean something like this. usepackagegcd and with this package findgcd command will be available to use it anywhere in document.
– user61681
10 hours ago
Is it possible to store this function as a package? I mean something like this. usepackagegcd and with this package findgcd command will be available to use it anywhere in document.
– user61681
10 hours ago
@user61681 Yes, write a package and upload it to CTAN.
– egreg
10 hours ago
@user61681 Yes, write a package and upload it to CTAN.
– egreg
10 hours ago
Could you share some resources? How to write package for this type of lua functions?
– user61681
10 hours ago
Could you share some resources? How to write package for this type of lua functions?
– user61681
10 hours ago
1
1
Thanks for your detailed help. You are great...! Just one last query, though it is out of scope here. I am trying to learn how to write latex macros (own commands, environments etc.). I couldn't find any resources for that. I have programming background but still find it difficult to learn latex programming. Could you share some resources if you know? Thanks again.
– user61681
9 hours ago
Thanks for your detailed help. You are great...! Just one last query, though it is out of scope here. I am trying to learn how to write latex macros (own commands, environments etc.). I couldn't find any resources for that. I have programming background but still find it difficult to learn latex programming. Could you share some resources if you know? Thanks again.
– user61681
9 hours ago
@user61681 It's best if they're documented.
– egreg
9 hours ago
@user61681 It's best if they're documented.
– egreg
9 hours ago
add a comment |
Thanks for contributing an answer to TeX - LaTeX Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f500932%2ffinding-greatest-common-divisor-using-lualatex%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown