Rosetta Code Task: "Josephus problem", obvious problem, but what is the correct way to fix?

Hi;

Rosetta Code Task: “Josephus problem”, obvious problem, but what is the correct way to correct it?

gnatmake ./josephus.adb
gcc -c -I./ -I- ./josephus.adb
josephus.adb:8:46: error: “Index” is undefined (more references follow)
gnatmake: “./josephus.adb” compilation error

function Arg(Idx, Default: Positive) return Positive is – read Argument(Idx)
(if Ada.Command_Line.Argument_Count >= Index
then Positive’Value(Ada.Command_Line.Argument(Index)) else Default);

What am I not understanding here?

Thanks,
Retired_Build_Engineer

“Obviously” that Index should be Idx.

The code has been wrong since it was uploaded in 2013!

1 Like

And the return type has to be Natural, in order to accept the 0 as intended for the 4th parameter.

I’ve fixed both problems in Rosetta Code.

That’s what I thought, but sometimes fixing a syntax error incorrectly will cause a logic error; at least while one is (re-)learning a language. That’s why I posted the query. Thanks for the response!