Skip to content

Instantly share code, notes, and snippets.

@kiyotune
Created August 20, 2012 04:59
Show Gist options
  • Save kiyotune/3401081 to your computer and use it in GitHub Desktop.
Save kiyotune/3401081 to your computer and use it in GitHub Desktop.
Project Euler 問題29 その2
#!/usr/local/bin/octave -q
% parse arguments
_argv = argv();
amin = str2num(char(_argv(1)));
amax = str2num(char(_argv(2)));
bmin = str2num(char(_argv(3)));
bmax = str2num(char(_argv(4)));
% calc
v = [amin:1:amax]'.^[amin:1:amax];
v = sort(unique(v));
ans = length(v);
% disp
printf("(%d<=a<=%d, %d<=b<=%d) Ans: %d\n", amin, amax, bmin, bmax, ans);
% <Answer>
% (2<=a<=100, 2<=b<=100) Ans: 9183
@kiyotune
Copy link
Author

すんなりできた。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment