In Bitcoin Whitepaper ( https://bitcoin.org/bitcoin.pdf ) on page 7, there is a C code snippet. The style, font and the size is very neat and proper. How can I apply this kind of style for my java code in TexStudio ( I am using TexLive)?
This is my java code:
import java.math.*;
public class successAttackerProbability {
public double calculateSuccessProbability(double q, int z) {
int i, k;
double p = 1.0 - q;
double lambda = z * (q / p);
double sum = 1.0;
for (k = 0; k <= z; k++) {
double poisson = Math.pow(Math.E, -lambda);
for (i = 1; i <= k; i++)
poisson *= lambda / i;
sum -= poisson * (1 - Math.pow(q / p, z - k));
}
System.out.println(sum);
return sum;
}
public static void main(String[] args) {
successAttackerProbability successAttackerProbability = new successAttackerProbability();
successAttackerProbability.calculateSuccessProbability(0.1, 1); // q =0.1 and z = 1
successAttackerProbability.calculateSuccessProbability(0.1, 2);
// ..
successAttackerProbability.calculateSuccessProbability(0.1, 10);
}
}
\lstset{basicstyle=\ttfamily}see daleifs answer solves your style problem? - Question without working code are harder to solve... compilable minimal code, starting with\documentclassand ending with\end{document}, helps a lot. – Bobyandbob Aug 21 '18 at 13:09ttfamilyis the font or i'm wrong? - RelatedSetting up specific font for use in listings – Bobyandbob Aug 21 '18 at 13:16