Codes: part 74

using SymPy
@vars x
X=x^2
subs(expand(x*subs(expand(x*subs(X,x^2,x+1)),x^2,x+1)),x^2,x+1
)

Advertisements

Codes: part 73

#!/usr/bin/ruby
include Math
require “mathn”
a=0
while a<=3
a +=1
sum1=a*a
b=0
while b<=3
b +=1
if a<=b
sum2=b*b
sum3=sum1+sum2
c=0
while c<=3
c +=1
sum4=c*c
d=0
while d<=3
d +=1
if c<=d
sum5=d*d
e=0
while e<=4
e +=1
if d<=e
sum6=e*e
sum7=sum4+sum5+sum6
if sum3 == sum7
print("",sum3," = ","",a,"^2 + ","",b,"^2", " = ","",c,"^2 + ","",d,"^2 + ",
"", e,"^2""\n")
end end end
end end end
end end end

 

Codes: part 70

import java.math.*;
public class prime{
public static void main (String[] args){
long a1,n1,d;
double b,c;
System.out.println(“2”);
for(n1=2; n1<190; n1++)
{b=Math.sqrt(n1);
c=Math.ceil(b)+1;
d=(long)c;
for(a1=2; a1<d; a1++)
{if(n1 % a1 == 0)
break;}
if(a1 == d)
System.out.println(n1);}}}